diff options
Diffstat (limited to 'src/compiler/optimize/postcss-scoped-styles')
-rw-r--r-- | src/compiler/optimize/postcss-scoped-styles/index.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/compiler/optimize/postcss-scoped-styles/index.ts b/src/compiler/optimize/postcss-scoped-styles/index.ts index 0d1253350..01c0acd94 100644 --- a/src/compiler/optimize/postcss-scoped-styles/index.ts +++ b/src/compiler/optimize/postcss-scoped-styles/index.ts @@ -12,6 +12,9 @@ interface Selector { const CSS_SEPARATORS = new Set([' ', ',', '+', '>', '~']); +/** HTML tags that should never get scoped classes */ +export const NEVER_SCOPED_TAGS = new Set<string>(['base', 'body', 'font', 'frame', 'frameset', 'head', 'html', 'link', 'meta', 'noframes', 'noscript', 'script', 'style', 'title']); + /** * Scope Selectors * Given a selector string (`.btn>span,.nav>span`), add an additional CSS class to every selector (`.btn.myClass>span.myClass,.nav.myClass>span.myClass`) @@ -62,6 +65,12 @@ export function scopeSelectors(selector: string, className: string) { continue; } + // don‘t scope body, title, etc. + if (NEVER_SCOPED_TAGS.has(value)) { + ss = head + value + tail; + continue; + } + // scope everything else let newSelector = ss.substring(start, end); const pseudoIndex = newSelector.indexOf(':'); |