Index: third_party/polymer/v1_0/components-chromium/iron-iconset-svg/iron-iconset-svg-extracted.js |
diff --git a/third_party/polymer/v1_0/components-chromium/iron-iconset-svg/iron-iconset-svg-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-iconset-svg/iron-iconset-svg-extracted.js |
index f1e7cb92cd0937e23f79f6b74b0f4137e6c766c3..5dc18de590dcd7aaf58b15e0fc8995dc96dbf24f 100644 |
--- a/third_party/polymer/v1_0/components-chromium/iron-iconset-svg/iron-iconset-svg-extracted.js |
+++ b/third_party/polymer/v1_0/components-chromium/iron-iconset-svg/iron-iconset-svg-extracted.js |
@@ -52,8 +52,25 @@ |
size: { |
type: Number, |
value: 24 |
+ }, |
+ |
+ /** |
+ * Set to true to enable mirroring of icons where specified when they are |
+ * stamped. Icons that should be mirrored should be decorated with a |
+ * `mirror-in-rtl` attribute. |
+ */ |
+ rtlMirroring: { |
+ type: Boolean, |
+ value: false |
+ } |
+ }, |
+ |
+ _targetIsRTL: function(target) { |
+ if (target && target.nodeType !== Node.ELEMENT_NODE) { |
+ target = target.host; |
} |
+ return target && window.getComputedStyle(target)['direction'] === 'rtl'; |
}, |
attached: function() { |
@@ -89,7 +106,8 @@ |
// Remove old svg element |
this.removeIcon(element); |
// install new svg element |
- var svg = this._cloneIcon(iconName); |
+ var svg = this._cloneIcon(iconName, |
+ this.rtlMirroring && this._targetIsRTL(element)); |
if (svg) { |
var pde = Polymer.dom(element); |
pde.insertBefore(svg, pde.childNodes[0]); |
@@ -106,6 +124,7 @@ |
*/ |
removeIcon: function(element) { |
// Remove old svg element |
+ element = element.root || element; |
if (element._svgIcon) { |
Polymer.dom(element).removeChild(element._svgIcon); |
element._svgIcon = null; |
@@ -148,28 +167,35 @@ |
* @return {Element} Returns an installable clone of the SVG element |
* matching `id`. |
*/ |
- _cloneIcon: function(id) { |
+ _cloneIcon: function(id, mirrorAllowed) { |
// create the icon map on-demand, since the iconset itself has no discrete |
// signal to know when it's children are fully parsed |
this._icons = this._icons || this._createIconMap(); |
- return this._prepareSvgClone(this._icons[id], this.size); |
+ return this._prepareSvgClone(this._icons[id], this.size, mirrorAllowed); |
}, |
/** |
* @param {Element} sourceSvg |
* @param {number} size |
+ * @param {Boolean} mirrorAllowed |
* @return {Element} |
*/ |
- _prepareSvgClone: function(sourceSvg, size) { |
+ _prepareSvgClone: function(sourceSvg, size, mirrorAllowed) { |
if (sourceSvg) { |
var content = sourceSvg.cloneNode(true), |
svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'), |
- viewBox = content.getAttribute('viewBox') || '0 0 ' + size + ' ' + size; |
+ viewBox = content.getAttribute('viewBox') || '0 0 ' + size + ' ' + size, |
+ cssText = 'pointer-events: none; display: block; width: 100%; height: 100%;'; |
+ |
+ if (mirrorAllowed && content.hasAttribute('mirror-in-rtl')) { |
+ cssText += '-webkit-transform:scale(-1,1);transform:scale(-1,1);'; |
+ } |
+ |
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.style.cssText = cssText; |
svg.appendChild(content).removeAttribute('id'); |
return svg; |
} |