Check for ShadyDOM and :dir selectors before trying css transform

Should save a considerable amount of style processing when not needed.
This commit is contained in:
Daniel Freedman
2018-10-31 16:37:22 -07:00
parent 1ad496fc7b
commit d290be9031

View File

@@ -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>}
*/
@@ -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;
}