fix(curriculum): use mediaText for CSSHelp (#42393)
* fix(curriculum): use mediaText in CSSHelp prevent selection of style elements with class or media attributes this should avoid picking up some browser extensions
This commit is contained in:
@@ -75,9 +75,9 @@ class CSSHelp {
|
||||
ele.style?.getPropertyValue(property)
|
||||
);
|
||||
}
|
||||
getRuleListsWithinMedia(conditionText: string): CSSStyleRule[] {
|
||||
getRuleListsWithinMedia(mediaText: string): CSSStyleRule[] {
|
||||
const medias = this.getCSSRules('media') as CSSMediaRule[];
|
||||
const cond = medias?.find(x => x.conditionText === conditionText);
|
||||
const cond = medias?.find(x => x?.media?.mediaText === mediaText);
|
||||
const cssRules = cond?.cssRules;
|
||||
return Array.from(cssRules || []) as CSSStyleRule[];
|
||||
}
|
||||
@@ -86,7 +86,10 @@ class CSSHelp {
|
||||
const link: HTMLLinkElement | null = this.doc?.querySelector(
|
||||
"link[href*='styles']"
|
||||
);
|
||||
const style: HTMLStyleElement | null = this.doc?.querySelector('style');
|
||||
// Most* browser extensions inject styles with class/media attributes
|
||||
const style: HTMLStyleElement | null = this.doc?.querySelector(
|
||||
'style:not([class]):not([media])'
|
||||
);
|
||||
if (link?.sheet?.cssRules?.length) {
|
||||
return link.sheet;
|
||||
} else if (style) {
|
||||
|
Reference in New Issue
Block a user