xmldom
xmldom copied to clipboard
Implement the selectors API
It would be nice if xmldom
could implement the W3C Selectors API (http://www.w3.org/TR/selectors-api/). Support can be easily added using an existing library such as nwmatcher
.
Example of using nwmatcher
s selector implementation with xmldom
:
global.document = api.loadSource().ownerDocument || api.loadSource(); // Set `document` object in fake "browser window" (node.js environment)
global.document.addEventListener = function() {}; // Workaround since `nwmatcher` otherwise thinks that the document was created by IE<9 and only supports `document.all` API
var matcher = nwmatcher(global); // Initialize `nwmatcher` for document
// Example of `.querySelector()`
var match = matcher.first(pattern, element);
:+1:
Indeed! I really would like to be able to use querySelector !
and querySelectorAll
This has been open for several years... no interest from the devs? These functions are really convenient.
xmlData.querySelector is not a function;
💔