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

selectors are case-sensitive, in violation of spec (because of a bug in a dependency) #3392

Closed
bakkot opened this issue Jul 2, 2022 · 1 comment · Fixed by #3540
Closed
Assignees
Labels
selectors CSS Selectors support

Comments

@bakkot
Copy link
Contributor

bakkot commented Jul 2, 2022

This is due to a bug in the latest version of nwsapi, which had its first release in three years nine days ago. But it affects JSDOM because this package does not pin a version of nwsapi. You might want to pin 2.2.0 until the linked bug gets fixed.


Minimal reproduction case

let { JSDOM } = require('jsdom');
let { document } = (new JSDOM('<p>')).window;
console.log([document.querySelector('P'), document.querySelector('p')]);
// prints [ null, HTMLParagraphElement {} ]

How does similar code behave in browsers?

Selectors are not case-sensitive, so both elements of the printed array are non-null.

@lysek
Copy link

lysek commented Jul 11, 2022

I encountered similar error with child selector during XML parsing (XML should be case-sensitive):

// run this in NodeJS, works OK in FF/Chrome (omit these two lines)
const { JSDOM } = require('jsdom');
const window = (new JSDOM()).window;

var parser = new window.DOMParser();
var doc = parser.parseFromString(`<elem>
    <Test>
        content
        <my-tag>abc</my-tag>
    </Test>
</elem>`, 'text/xml');

console.assert(doc.querySelectorAll('Test').length == 1, 'Test tag not found');
console.assert(doc.querySelectorAll('test').length == 0, 'test tag exists');
console.assert(doc.querySelectorAll('my-tag').length == 1, 'my-tag tag not found');
console.assert(doc.querySelectorAll('Test>my-tag').length == 1, 'Test>tag not found');

@domenic domenic added the selectors CSS Selectors support label Oct 1, 2022
@domenic domenic self-assigned this May 1, 2023
domenic added a commit that referenced this issue May 1, 2023
This fixes at least a few case-sensitivity bugs, as shown in the new test.

Closes #3392. Closes #3428. Closes #3416. Closes #3528 by superseding it.
@domenic domenic mentioned this issue May 1, 2023
domenic added a commit that referenced this issue May 1, 2023
This fixes at least a few case-sensitivity bugs, as shown in the new test.

Closes #3392. Closes #3428. Closes #3416. Closes #3528 by superseding it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
selectors CSS Selectors support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants