jsdom: `querySelector` cannot resolve selectors with escaped IDs
For example, as a CSS selector, ID as "0foo.000"
requires escape the first "0"
and "."
at least.
Current browsers also have CSS.escape(str)
builtin for escaping any IDs.
But the current jsdom (9.4.0) cannot resolve the ID above. the code as:
"use strict";
const jsdom = require("jsdom");
const document = jsdom.jsdom();
//(same codes on web console and nodejs)
const elems = document.createElement("div");
const a = document.createElement("span");
a.id = "0foo.000";
elems.appendChild(a);
//fail with jsdom but pass on browsers
console.assert(elems.querySelector("#\\30 foo\\.000") === a);
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (3 by maintainers)
Commits related to this issue
- WIP for CSS escaped identifier: if available, but only when necessary, use String.fromCodePoint() instead of String.fromCharCode(). This is to keep performances and compatibility. — committed to dperini/nwmatcher by dperini 8 years ago
- WIP for CSS escaped identifier: fixed codepoints and ranges that must be replaced by '\ufffd' (@bellbind) — committed to dperini/nwmatcher by dperini 8 years ago
- Add more selector tests Closes #1550. Drawn from https://github.com/tmpvar/jsdom/issues/1550#issuecomment-232588346. — committed to jsdom/jsdom by domenic 8 years ago
- Add more selector tests Closes #1550. Drawn from https://github.com/tmpvar/jsdom/issues/1550#issuecomment-232588346. — committed to jsdom/jsdom by domenic 8 years ago
- Add more selector tests Closes #1550. Drawn from https://github.com/tmpvar/jsdom/issues/1550#issuecomment-232588346. — committed to jsdom/jsdom by domenic 8 years ago
- Add more selector tests Closes #1550. Drawn from https://github.com/tmpvar/jsdom/issues/1550#issuecomment-232588346. — committed to nhunzaker/jsdom by domenic 8 years ago
Doing jest dom manipulation test with jsdom as test environment, found out CSS is not defined. Seems that it is not implemented.