From 30833980c4dba33f7a6ea80f3759ace1796b747d Mon Sep 17 00:00:00 2001 From: "Scott J. Miles" Date: Wed, 4 Sep 2013 17:45:41 -0700 Subject: [PATCH] improve theme handling code --- polymer-ui-icon/polymer-ui-icon.html | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/polymer-ui-icon/polymer-ui-icon.html b/polymer-ui-icon/polymer-ui-icon.html index 1aa2420..5309863 100644 --- a/polymer-ui-icon/polymer-ui-icon.html +++ b/polymer-ui-icon/polymer-ui-icon.html @@ -1,9 +1,9 @@ - + + @@ -136,25 +137,20 @@ this.updateIcon(); }, themeChanged: function(old) { + this.super(arguments); this.style.backgroundPosition = ''; - this.classList.switch(old, this.theme); this.bx = calcThemeOffset(this.theme, this); - this.asyncMethod('updateIcon'); + this.updateIcon(); }, updateIcon: function() { if (this.src) { this.style.backgroundPosition = 'center'; } else { - // TODO(sorvell): FF cannot set Y only so we go to trouble - // to find the x offset and use it here. this.style.backgroundPosition = (this.bx + 'px') + ' ' + (this.by + 'px'); - //this.style.backgroundPositionY = this.by + 'px'; } } }); - - // memoize offset by theme name since getComputedStyle - // is $$ + // memoize offset because getComputedStyle is expensive var themes = {}; function calcThemeOffset(theme, node) { if (themes[theme] === undefined) {