Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuerySelector fail - Color attribute value mistaken for ID #660

Open
itutto opened this issue Nov 20, 2022 · 1 comment
Open

QuerySelector fail - Color attribute value mistaken for ID #660

itutto opened this issue Nov 20, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@itutto
Copy link
Contributor

itutto commented Nov 20, 2022

Describe the bug
The queryselector will mistakenly categorizes the selector as an ID selector if the selector contains an # symbol.

this.isID = !this.isAll ? selector.indexOf('#') !== -1 : false;

The # symbol can also be used without escaping for attribute values such as colour. [fill=#111].

To Reproduce
Steps to reproduce the behavior:
Try to QuerySelect for elements with # symbol in their attributes.

var happyDom = require("happy-dom")
const win = new happyDom.Window();

win.document.body.innerHTML = `<svg width=10px height=10px xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20"><path fill="#111" d="M5 5L15 5L15 15L5 15"></path></svg>`;


const allpaths = win.document.querySelectorAll('path[fill="#111"]');
console.log('all paths: ' + allpaths.length); // This will return 0

Expected behavior
The QuerySelector should find elements with # in their attribute values. ie: [fill=#111]

@itutto itutto added the bug Something isn't working label Nov 20, 2022
@btea
Copy link
Contributor

btea commented Feb 24, 2023

It seems to have been fixed by #662 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants