GithubHelp home page GithubHelp logo

domselector's People

Contributors

asamuzak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

domselector's Issues

`:defined` pseudo-class is missing

:defined

wpt tests are:

  • css/selectors/invalidation/defined.html
  • css/selectors/invalidation/defined-in-has.html

Add support for it or add it in unsupported pseudo-class list.

Do you know how nwmatcher is so fast?

I have a small idea for performance work, which may be good or may be bad. I wanted to share it with you in case it was helpful.

Basically, if you take a benchmark where nwmatcher is fast, have you looked at how it does its work? And how that work compares to dom-selector? Can dom-selector switch to nwmatcher's strategy? Doing so might require ugly special cases or fast paths, but maybe it is worth it.

Feel free to close this if it is not helpful.

TypeError: Cannot read properties of null (reading 'createTreeWalker')

I use Vue 2 + Vitest + JsDom for running component tests.
Since JsDom changed to you package my tests are failing.

I'm currently unable to create a minimal repo to demonstrate this issue.

However I tried to debug it and it comes down to this code section.

let parent = node;
while (parent) {
  if (parent.parentNode) {
    parent = parent.parentNode;
  } else {
    break;
  }
}
document = parent.ownerDocument;
root = parent;

https://github.com/asamuzaK/domSelector/blame/c0b90ba4dcf7a58c3aa3e852e476c5707b398356/src/js/matcher.js#L147C11-L156C25

After the closest method is called on an HTML Element this section is executed. By the end document is null and therefore throws an error here:

const walker = document.createTreeWalker(root, filter);

https://github.com/asamuzaK/domSelector/blame/c0b90ba4dcf7a58c3aa3e852e476c5707b398356/src/js/matcher.js#L173

I looked into the state of the while loop before the error was thrown:

  • Button
  • Div
  • Body
  • Html
  • Doument -> break

The loop break if parent is Document, however on Document there is no ownerDocument (https://developer.mozilla.org/en-US/docs/Web/API/Node/ownerDocument), resulting in document beeing null and thus causing the issue when running document.createTreeWalker

@asamuzaK Do you have any tests implemented to tests this part of your if-else-statement for the case ELEMENT_NODE?
If so, where do I find it, so I can try to demonstrate the issue. If not, could you please make sure the while loop is working as intended. Thanks!

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.