From 0755e8af2105ae3c602dc6c8b21d8b3540e120a9 Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Wed, 20 Nov 2013 15:55:21 -0800 Subject: [PATCH] =?UTF-8?q?Use=20a=20less=20likely=20to=20collide=20name?= =?UTF-8?q?=20for=20=E2=80=98host=E2=80=99=20when=20parsing=20via=20cssom.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ShadowCSS.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ShadowCSS.js b/src/ShadowCSS.js index a8dbfee..316fda6 100644 --- a/src/ShadowCSS.js +++ b/src/ShadowCSS.js @@ -518,15 +518,16 @@ var hostRuleRe = /@host[^{]*{(([^}]*?{[^{]*?}[\s\S]*?)+)}/gim, cssPolyfillUnscopedRuleCommentRe = /\/\*\s@polyfill-unscoped-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim, cssPseudoRe = /::(x-[^\s{,(]*)/gim, cssPartRe = /::part\(([^)]*)\)/gim, - // note: :host pre-processed to -host. - cssColonHostRe = /(-host)(?:\(([^)]*)\))?([^,{]*)/gim, + // note: :host pre-processed to -shadowcsshost. + polyfillHost = '-shadowcsshost', + cssColonHostRe = new RegExp('(' + polyfillHost + + ')(?:\\(([^)]*)\\))?([^,{]*)', 'gim'), selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$', hostRe = /@host/gim, colonHostRe = /\:host/gim, - polyfillHost = '-host', /* host name without combinator */ - polyfillHostNoCombinator = '-host-no-combinator', - polyfillHostRe = /-host/gim; + polyfillHostNoCombinator = polyfillHost + '-no-combinator', + polyfillHostRe = new RegExp(polyfillHost, 'gim'); function stylesToCssText(styles, preserveComments) { var cssText = '';