skip malformed css selector (#3577)
This commit is contained in:
@@ -763,7 +763,11 @@ function isHoverPointerElement(element, hoverStylesMap) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (shouldMatch || selector.includes(tagName)) {
|
if (shouldMatch || selector.includes(tagName)) {
|
||||||
if (element.matches(selector) && styles.cursor === "pointer") {
|
if (
|
||||||
|
isValidCSSSelector(selector) &&
|
||||||
|
element.matches(selector) &&
|
||||||
|
styles.cursor === "pointer"
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2192,6 +2196,11 @@ async function getHoverStylesMap() {
|
|||||||
// Get base selector without :hover
|
// Get base selector without :hover
|
||||||
const baseSelector = hoverPart.replace(/:hover/g, "").trim();
|
const baseSelector = hoverPart.replace(/:hover/g, "").trim();
|
||||||
|
|
||||||
|
// Skip invalid CSS selectors
|
||||||
|
if (!isValidCSSSelector(baseSelector)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Get or create styles object for this selector
|
// Get or create styles object for this selector
|
||||||
let styles = hoverMap.get(baseSelector) || {};
|
let styles = hoverMap.get(baseSelector) || {};
|
||||||
|
|
||||||
@@ -2204,13 +2213,16 @@ async function getHoverStylesMap() {
|
|||||||
// store it in a special format
|
// store it in a special format
|
||||||
if (parts.length > 1) {
|
if (parts.length > 1) {
|
||||||
const fullSelector = selector;
|
const fullSelector = selector;
|
||||||
styles["__nested__"] = styles["__nested__"] || [];
|
// Skip if the full selector is invalid
|
||||||
styles["__nested__"].push({
|
if (isValidCSSSelector(fullSelector)) {
|
||||||
selector: fullSelector,
|
styles["__nested__"] = styles["__nested__"] || [];
|
||||||
styles: Object.fromEntries(
|
styles["__nested__"].push({
|
||||||
[...rule.style].map((prop) => [prop, rule.style[prop]]),
|
selector: fullSelector,
|
||||||
),
|
styles: Object.fromEntries(
|
||||||
});
|
[...rule.style].map((prop) => [prop, rule.style[prop]]),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only need the style which includes the cursor attribute.
|
// only need the style which includes the cursor attribute.
|
||||||
|
|||||||
Reference in New Issue
Block a user