-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
Similar to #28, if an element's class name begins with a number, we get the same DOM error:
Uncaught DOMException: Failed to execute 'querySelectorAll' on 'Element': '#x0.987954339334459x1624591192249' is not a valid selector.
Following the fix for #28 in #34, below is my local fix of the library using patch-package
.
But it might be worth just filtering any invalid class names?
index 858bfd6..42463ea 100644
--- a/node_modules/unique-selector/lib/getClasses.js
+++ b/node_modules/unique-selector/lib/getClasses.js
@@ -42,6 +42,7 @@ function getClasses(el) {
function getClassSelectors(el) {
var classList = getClasses(el).filter(Boolean);
return classList.map(function (cl) {
- return '.' + cl;
+ // if the CLASS starts with a number or contains ":" selecting with a dot will cause a DOMException
+ return cl.match(/(?:^\d|:)/) ? '[class*="' + cl + '"]' : '.' + cl;
});
}
Metadata
Metadata
Assignees
Labels
No labels