diff --git a/lib/mixins/dir-mixin.html b/lib/mixins/dir-mixin.html index c029ed3e37..24752e3f71 100644 --- a/lib/mixins/dir-mixin.html +++ b/lib/mixins/dir-mixin.html @@ -19,6 +19,10 @@ const EL_DIR = /([\s\w-#\.\[\]\*]*):dir\((ltr|rtl)\)/g; const EL_DIR_REPLACMENT = ':host([dir="$2"]) $1'; + const DIR_CHECK = /:dir\((?:ltr|rtl)\)/; + + const SHIM_SHADOW = Boolean(window['ShadyDOM'] && window['ShadyDOM']['inUse']); + /** * @type {!Array} */ @@ -80,10 +84,12 @@ */ Polymer.DirMixin = Polymer.dedupingMixin((base) => { - if (!observer) { - getRTL(); - observer = new MutationObserver(updateDirection); - observer.observe(document.documentElement, {attributes: true, attributeFilter: ['dir']}); + if (!SHIM_SHADOW) { + if (!observer) { + getRTL(); + observer = new MutationObserver(updateDirection); + observer.observe(document.documentElement, {attributes: true, attributeFilter: ['dir']}); + } } /** @@ -107,7 +113,10 @@ */ static _processStyleText(cssText, baseURI) { cssText = super._processStyleText(cssText, baseURI); - cssText = this._replaceDirInCssText(cssText); + if (!SHIM_SHADOW && DIR_CHECK.test(cssText)) { + cssText = this._replaceDirInCssText(cssText); + this.__activateDir = true; + } return cssText; } @@ -121,9 +130,6 @@ let replacedText = text; replacedText = replacedText.replace(HOST_DIR, HOST_DIR_REPLACMENT); replacedText = replacedText.replace(EL_DIR, EL_DIR_REPLACMENT); - if (text !== replacedText) { - this.__activateDir = true; - } return replacedText; } diff --git a/test/unit/dir.html b/test/unit/dir.html index 0cc008246d..d38fe41312 100644 --- a/test/unit/dir.html +++ b/test/unit/dir.html @@ -217,6 +217,9 @@ }); test('elements with dir attribute explicitly set will not change', function() { + if (window.ShadyDOM && window.ShadyDOM.inUse) { + this.skip(); + } let inner = fixture('preset'); assert.equal(document.documentElement.getAttribute('dir'), 'rtl'); assertComputed(inner.shadowRoot.querySelector('.special > div'), 'rgb(255, 255, 255)', 'color'); @@ -245,6 +248,9 @@ }); test('complicated setup', function() { + if (window.ShadyDOM && window.ShadyDOM.inUse) { + this.skip(); + } let el = fixture('complicated'); assertComputed(el.$.direct, '10px'); assertComputed(el.$.indirect, '9px');