diff --git a/iron-iconset-svg.html b/iron-iconset-svg.html index 63e7dbc..2123d02 100644 --- a/iron-iconset-svg.html +++ b/iron-iconset-svg.html @@ -187,20 +187,33 @@ }, /** - * - * When name is changed, register iconset metadata - * + * Fire 'iron-iconset-added' event at next microtask. */ - _nameChanged: function() { - this._meta.value = null; - this._meta.key = this.name; - this._meta.value = this; - + _fireIronIconsetAdded: function() { this.async(function() { this.fire('iron-iconset-added', this, {node: window}); }); }, + /** + * + * When name is changed, register iconset metadata + * + */ + _nameChanged: function() { + this._meta.value = null; + this._meta.key = this.name; + this._meta.value = this; + if (this.ownerDocument && this.ownerDocument.readyState === 'loading') { + // Document still loading. It could be that not all icons in the iconset are parsed yet. + this.ownerDocument.addEventListener('DOMContentLoaded', function() { + this._fireIronIconsetAdded(); + }.bind(this)); + } else { + this._fireIronIconsetAdded(); + } + }, + /** * Create a map of child SVG elements by id. * diff --git a/test/imported.html b/test/imported.html new file mode 100644 index 0000000..e0a2173 --- /dev/null +++ b/test/imported.html @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/test/iron-iconset-svg.html b/test/iron-iconset-svg.html index a65b1ae..a709abf 100644 --- a/test/iron-iconset-svg.html +++ b/test/iron-iconset-svg.html @@ -88,6 +88,12 @@ + + + +