Comments (7)
Line 452 in 816c909
from nwsapi.
And, as alluded to in #1,
Line 477 in 816c909
from nwsapi.
I wonder if install/uninstall could be removed from the jsdom-facing version entirely.
Sure I could remove that completely ... however I am trying to have only one version for both browsers and 'jsdom' and for browsers I am trying to give an easy path to users to replace the native QSA API with 'nwsapi'. Given that the 'install/uninstall' methods are not invoked/used in the code anywhere my suggestion is to slightly change my code to never be executed by 'jsdom' nor use 'Element'' interface but still leave it in. This means moving the placeholder assignment inside the methods and just leave the globals out.
If you agree with this extra payload of a few hundred bytes I may be able to keep both kind of users happy. I will commit a change in the code for you to review in a few hours.
Also if you see browsers implementation errors in install/uninstall maybe you can help improve those methods.
Do you find this to be an acceptable compromise ?
from nwsapi.
Still pending a resolution about install/uninstall methods in the comments of issue #2.
from nwsapi.
Sure, it's fine to keep them. It does require jsdom pass dummy versions of Element, Document etc. to nwsapi (objects with a single property, prototype, which is an empty object). This is kind of a silly API for a Node module to have, where you always have to give it dummy objects before it can work. But we can use it.
from nwsapi.
Here is how we use nwsapi in my local branch, so you can see what I mean:
const DOMException = require("domexception");
// TODO: remove these workarounds depending on how https://github.com/dperini/nwsapi/issues/2 goes.
const dummy = { prototype: {} };
function dummyXMLDocument() { } // TODO maybe this should be better. Probably we do want different XML selector behavior.
function createNWSAPI(document) {
const nwsapiInstance = nwsapi({
document,
DOMException,
Element: dummy,
Document: dummy,
XMLDocument: dummyXMLDocument
});
nwsapiInstance.configure({ VERBOSITY: false });
return nwsapiInstance;
}
This is using a hacked copy of nwmatcher where I just added global.
before everything.
from nwsapi.
Oh, I didn't see that you changed this in 6bc9e06. That fix looks pretty good and I've confirmed it works in jsdom. So I'll close this :)
from nwsapi.
Related Issues (20)
- :scope selector direct children query is not working because of tag name resolution strategy HOT 4
- Tag with an uppercase letter is not working as expected in XML HOT 2
- querySelector > E HOT 1
- Id starting with digit throws SyntaxError: '...' is not a valid selector HOT 4
- unknown pseudo-class selector ':is(:is(button, input)[type=submit]' HOT 2
- Pseudo-class `:is()` should not fail on empty arg or invalid selectors in arg HOT 1
- Error on parenthesis in attribute value inside pseudo-class arg HOT 1
- Missing support for :has() pseudo-class HOT 5
- TypeError: Cannot read properties of undefined (reading 'toLowerCase') HOT 10
- TypeError: Cannot read properties of null (reading 'parentElement') HOT 4
- Publish a new release HOT 2
- unknown pseudo-class selector ':defined' HOT 1
- Upgrade from nwsapi 2.2.2 to 2.2.3 creates infinite loop HOT 12
- v2.2.3 DOMException [SyntaxError]: '.disabled):not(:disabled)' is not a valid selector HOT 26
- fix: v2.2.3 was broken and v2.2.4 it was not published on npm HOT 3
- Infinite loop fixed but still getting error in selectors HOT 25
- Attribute selector ~= does not handle escaped values correctly
- Concatenated `:not` selector doesn't work since version `2.2.3` HOT 1
- logicalsel Rexexp selects incorrect values since 2.2.3 HOT 5
- Not a valid selector HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nwsapi.