ApplicationImpl cleanup, part 1:
[chromium-blink-merge.git] / third_party / polymer / v1_0 / components-chromium / iron-icon / iron-icon-extracted.js
blob0f1add2736429dde45d555f770d1742aaa0d136e
3 Polymer({
5 is: 'iron-icon',
7 properties: {
9 /**
10 * The name of the icon to use. The name should be of the form:
11 * `iconset_name:icon_name`.
13 icon: {
14 type: String,
15 observer: '_iconChanged'
18 /**
19 * The name of the theme to used, if one is specified by the
20 * iconset.
22 theme: {
23 type: String,
24 observer: '_updateIcon'
27 /**
28 * If using iron-icon without an iconset, you can set the src to be
29 * the URL of an individual icon image file. Note that this will take
30 * precedence over a given icon attribute.
32 src: {
33 type: String,
34 observer: '_srcChanged'
38 _DEFAULT_ICONSET: 'icons',
40 _iconChanged: function(icon) {
41 var parts = (icon || '').split(':');
42 this._iconName = parts.pop();
43 this._iconsetName = parts.pop() || this._DEFAULT_ICONSET;
44 this._updateIcon();
47 _srcChanged: function(src) {
48 this._updateIcon();
51 _usesIconset: function() {
52 return this.icon || !this.src;
55 _updateIcon: function() {
56 if (this._usesIconset()) {
57 if (this._iconsetName) {
58 this._iconset = this.$.meta.byKey(this._iconsetName);
59 if (this._iconset) {
60 this._iconset.applyIcon(this, this._iconName, this.theme);
61 } else {
62 this._warn(this._logf('_updateIcon', 'could not find iconset `'
63 + this._iconsetName + '`, did you import the iconset?'));
66 } else {
67 if (!this._img) {
68 this._img = document.createElement('img');
69 this._img.style.width = '100%';
70 this._img.style.height = '100%';
72 this._img.src = this.src;
73 Polymer.dom(this.root).appendChild(this._img);
77 });