chek is CSSGroupingRule supported (#693)
This commit is contained in:
@@ -60,6 +60,8 @@ type WindowWithAngularZone = Window & {
|
|||||||
|
|
||||||
export const mutationBuffers: MutationBuffer[] = [];
|
export const mutationBuffers: MutationBuffer[] = [];
|
||||||
|
|
||||||
|
const isCSSGroupingRuleSupported = typeof CSSGroupingRule !== "undefined"
|
||||||
|
|
||||||
function getEventTarget(event: Event): EventTarget | null {
|
function getEventTarget(event: Event): EventTarget | null {
|
||||||
try {
|
try {
|
||||||
if ('composedPath' in event) {
|
if ('composedPath' in event) {
|
||||||
@@ -476,7 +478,7 @@ function initInputObserver(
|
|||||||
function getNestedCSSRulePositions(rule: CSSRule): number[] {
|
function getNestedCSSRulePositions(rule: CSSRule): number[] {
|
||||||
const positions: number[] = [];
|
const positions: number[] = [];
|
||||||
function recurse(childRule: CSSRule, pos: number[]) {
|
function recurse(childRule: CSSRule, pos: number[]) {
|
||||||
if (childRule.parentRule instanceof CSSGroupingRule) {
|
if (isCSSGroupingRuleSupported && childRule.parentRule instanceof CSSGroupingRule) {
|
||||||
const rules = Array.from(
|
const rules = Array.from(
|
||||||
(childRule.parentRule as CSSGroupingRule).cssRules,
|
(childRule.parentRule as CSSGroupingRule).cssRules,
|
||||||
);
|
);
|
||||||
@@ -520,6 +522,13 @@ function initStyleSheetObserver(
|
|||||||
return deleteRule.apply(this, arguments);
|
return deleteRule.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!isCSSGroupingRuleSupported) {
|
||||||
|
return () => {
|
||||||
|
CSSStyleSheet.prototype.insertRule = insertRule;
|
||||||
|
CSSStyleSheet.prototype.deleteRule = deleteRule;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const groupingInsertRule = CSSGroupingRule.prototype.insertRule;
|
const groupingInsertRule = CSSGroupingRule.prototype.insertRule;
|
||||||
CSSGroupingRule.prototype.insertRule = function (
|
CSSGroupingRule.prototype.insertRule = function (
|
||||||
rule: string,
|
rule: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user