js: Only use ids in Utils.getCSSPath() if they're truly unique

This commit is contained in:
Johannes Meyer 2022-02-04 17:22:16 +01:00
parent 4f501a89f5
commit fe6be6a107
1 changed files with 2 additions and 2 deletions

View File

@ -373,8 +373,8 @@
while (true) {
var id = element.id;
// Ignore forms and form controls because id generation is unreliable :(
if (id && ! element.form && ! (element instanceof HTMLFormElement)) {
// Only use ids if they're truly unique
if (!! id && document.querySelectorAll('* #' + id).length === 1) {
path.push('#' + id);
break;
}