Coder Social home page Coder Social logo

Comments (7)

domenic avatar domenic commented on July 28, 2024

doc.createElement('DiV').nodeName != 'DiV' && !(doc instanceof XMLDocument);
also has this problem

from nwsapi.

domenic avatar domenic commented on July 28, 2024

And, as alluded to in #1,

err = new DOMException(message, SyntaxError());

from nwsapi.

dperini avatar dperini commented on July 28, 2024

@domenic,

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.

dperini avatar dperini commented on July 28, 2024

Issues #1 and #2 were fixed.

Still pending a resolution about install/uninstall methods in the comments of issue #2.

from nwsapi.

domenic avatar domenic commented on July 28, 2024

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.

domenic avatar domenic commented on July 28, 2024

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.

domenic avatar domenic commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.