Skip to content

Commit

Permalink
Check for ShadyDOM and :dir selectors before trying css transform
Browse files Browse the repository at this point in the history
Should save a considerable amount of style processing when not needed.
  • Loading branch information
dfreedm committed Oct 31, 2018
1 parent 1ad496f commit d290be9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/mixins/dir-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const HOST_DIR_REPLACMENT = ':host([dir="$1"])';
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<!Polymer_DirMixin>}
*/
Expand Down Expand Up @@ -107,7 +111,9 @@ export const DirMixin = dedupingMixin((base) => {
*/
static _processStyleText(cssText, baseURI) {
cssText = super._processStyleText(cssText, baseURI);
cssText = this._replaceDirInCssText(cssText);
if (!SHIM_SHADOW && DIR_CHECK.test(cssText)) {
cssText = this._replaceDirInCssText(cssText);
}
return cssText;
}

Expand Down

0 comments on commit d290be9

Please sign in to comment.