Skip to content

Commit

Permalink
Merge pull request #15 from PolymerElements/fix-bogus-warning
Browse files Browse the repository at this point in the history
don't try to initialize before `_iconsetName` is valued
  • Loading branch information
cdata committed May 28, 2015
2 parents 625ea1e + a294006 commit b6c3635
Showing 1 changed file with 70 additions and 68 deletions.
138 changes: 70 additions & 68 deletions iron-icon.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,83 +103,85 @@
<iron-meta id="meta" type="iconset"></iron-meta>
</template>

</dom-module>

<script>

Polymer({

is: 'iron-icon',
<script>

Polymer({

is: 'iron-icon',

properties: {

/**
* The name of the icon to use. The name should be of the form:
* `iconset_name:icon_name`.
*/
icon: {
type: String,
observer: '_iconChanged'
},

/**
* The name of the theme to used, if one is specified by the
* iconset.
*/
theme: {
type: String,
observer: '_updateIcon'
},

/**
* If using iron-icon without an iconset, you can set the src to be
* the URL of an individual icon image file. Note that this will take
* precedence over a given icon attribute.
*/
src: {
type: String,
observer: '_srcChanged'
}
},

properties: {
_DEFAULT_ICONSET: 'icons',

/**
* The name of the icon to use. The name should be of the form:
* `iconset_name:icon_name`.
*/
icon: {
type: String,
observer: '_iconChanged'
_iconChanged: function(icon) {
var parts = (icon || '').split(':');
this._iconName = parts.pop();
this._iconsetName = parts.pop() || this._DEFAULT_ICONSET;
this._updateIcon();
},

/**
* The name of the theme to used, if one is specified by the
* iconset.
*/
theme: {
type: String,
observer: '_updateIcon'
_srcChanged: function(src) {
this._updateIcon();
},

/**
* If using iron-icon without an iconset, you can set the src to be
* the URL of an individual icon image file. Note that this will take
* precedence over a given icon attribute.
*/
src: {
type: String,
observer: '_srcChanged'
}

},

_DEFAULT_ICONSET: 'icons',

_iconChanged: function(icon) {
var parts = (icon || '').split(':');
this._iconName = parts.pop();
this._iconsetName = parts.pop() || this._DEFAULT_ICONSET;
this._updateIcon();
},

_srcChanged: function(src) {
this._updateIcon();
},

_usesIconset: function() {
return this.icon || !this.src;
},
_usesIconset: function() {
return this.icon || !this.src;
},

_updateIcon: function() {
if (this._usesIconset()) {
this._iconset = this.$.meta.byKey(this._iconsetName);
if (this._iconset) {
this._iconset.applyIcon(this, this._iconName, this.theme);
_updateIcon: function() {
if (this._usesIconset()) {
if (this._iconsetName) {
this._iconset = this.$.meta.byKey(this._iconsetName);
if (this._iconset) {
this._iconset.applyIcon(this, this._iconName, this.theme);
} else {
this._warn(this._logf('_updateIcon', 'could not find iconset `'
+ this._iconsetName + '`, did you import the iconset?'));
}
}
} else {
console.warn('iron-icon: could not find iconset `'
+ this._iconsetName + '`, did you import the iconset?');
}
} else {
if (!this._img) {
this._img = document.createElement('img');
this._img.style.width = '100%';
this._img.style.height = '100%';
if (!this._img) {
this._img = document.createElement('img');
this._img.style.width = '100%';
this._img.style.height = '100%';
}
this._img.src = this.src;
Polymer.dom(this.root).appendChild(this._img);
}
this._img.src = this.src;
Polymer.dom(this.root).appendChild(this._img);
}
}

});
});

</script>

</dom-module>

</script>

0 comments on commit b6c3635

Please sign in to comment.