Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
update users when the iconset is loaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Jun 16, 2014
1 parent 91d0736 commit 91930ae
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions core-iconset-svg.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
iconSize: 24,
type: 'iconset',

ready: function() {
this.super();
this.updateIcons();
},

iconById: function(id) {
return this.querySelector('#' + id);
},
Expand Down Expand Up @@ -129,7 +134,31 @@
}
svg.style.display = 'block';
root.insertBefore(svg, root.firstElementChild);
},

/**
* Tell users of the iconset, that the set has loaded.
* This finds all elements matching the selector argument and calls
* the method argument on them.
* @method updateIcons
* @param selector {string} css selector to identify iconset users,
* defaults to '[icon]'
* @param method {string} method to call on found elements,
* defaults to 'updateIcon'
*/
updateIcons: function(selector, method) {
selector = selector || '[icon]';
method = method || 'updateIcon';
var deep = window.ShadowDOMPolyfill ? '' : 'html /deep/ ';
var i$ = document.querySelectorAll(deep + selector);
for (var i=0, e; e=i$[i]; i++) {
if (e[method]) {
e[method].call(e);
}
}
}


});

</script>
Expand Down

0 comments on commit 91930ae

Please sign in to comment.