Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Unified Diff: lib/src/iron-iconset-svg/iron-iconset-svg.html

Issue 1418513006: update elements and fix some bugs (Closed) Base URL: git@github.com:dart-lang/polymer_elements.git@master
Patch Set: code review updates Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/iron-icons/iron-icons.html ('k') | lib/src/iron-iconset-svg/test/iron-iconset-svg.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/iron-iconset-svg/iron-iconset-svg.html
diff --git a/lib/src/iron-iconset-svg/iron-iconset-svg.html b/lib/src/iron-iconset-svg/iron-iconset-svg.html
index 3cebc2ce1d3283ff6e61dc514cd7699706de4de4..da20aee4ffba2b8eb65d70e27afa9496d488c7fc 100644
--- a/lib/src/iron-iconset-svg/iron-iconset-svg.html
+++ b/lib/src/iron-iconset-svg/iron-iconset-svg.html
@@ -18,9 +18,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* `iron-iconset-svg` element. Multiple icons should be given distinct id's.
*
* Using svg elements to create icons has a few advantages over traditional
- * bitmap graphics like jpg or png. Icons that use svg are vector based so they
- * are resolution independent and should look good on any device. They are
- * stylable via css. Icons can be themed, colorized, and even animated.
+ * bitmap graphics like jpg or png. Icons that use svg are vector based so
+ * they are resolution independent and should look good on any device. They
+ * are stylable via css. Icons can be themed, colorized, and even animated.
*
* Example:
*
@@ -45,18 +45,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*
* @element iron-iconset-svg
* @demo demo/index.html
+ * @implements {Polymer.Iconset}
*/
Polymer({
-
is: 'iron-iconset-svg',
properties: {
/**
* The name of the iconset.
- *
- * @attribute name
- * @type string
*/
name: {
type: String,
@@ -65,10 +62,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
/**
* The size of an individual icon. Note that icons must be square.
- *
- * @attribute iconSize
- * @type number
- * @default 24
*/
size: {
type: Number,
@@ -76,6 +69,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
},
+
+ attached: function() {
+ this.style.display = 'none';
+ },
/**
* Construct an array of all icon names in this iconset.
@@ -98,7 +95,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* @method applyIcon
* @param {Element} element Element to which the icon is applied.
* @param {string} iconName Name of the icon to apply.
- * @return {Element} The svg element which renders the icon.
+ * @return {?Element} The svg element which renders the icon.
*/
applyIcon: function(element, iconName) {
// insert svg element into shadow root, if it exists
@@ -136,6 +133,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/
_nameChanged: function() {
new Polymer.IronMeta({type: 'iconset', key: this.name, value: this});
+ this.async(function() {
+ this.fire('iron-iconset-added', this, {node: window});
+ });
},
/**
@@ -176,13 +176,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/
_prepareSvgClone: function(sourceSvg, size) {
if (sourceSvg) {
- var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
- svg.setAttribute('viewBox', ['0', '0', size, size].join(' '));
+ var content = sourceSvg.cloneNode(true),
+ svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'),
+ viewBox = content.getAttribute('viewBox') || '0 0 ' + size + ' ' + size;
+ svg.setAttribute('viewBox', viewBox);
svg.setAttribute('preserveAspectRatio', 'xMidYMid meet');
// TODO(dfreedm): `pointer-events: none` works around https://crbug.com/370136
// TODO(sjmiles): inline style may not be ideal, but avoids requiring a shadow-root
svg.style.cssText = 'pointer-events: none; display: block; width: 100%; height: 100%;';
- svg.appendChild(sourceSvg.cloneNode(true)).removeAttribute('id');
+ svg.appendChild(content).removeAttribute('id');
return svg;
}
return null;
« no previous file with comments | « lib/src/iron-icons/iron-icons.html ('k') | lib/src/iron-iconset-svg/test/iron-iconset-svg.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698