Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h1 + h2 appears to break #114

Open
Fil opened this issue May 13, 2024 · 4 comments
Open

h1 + h2 appears to break #114

Fil opened this issue May 13, 2024 · 4 comments

Comments

@Fil
Copy link

Fil commented May 13, 2024

This selector errors after c104f8c; it's working with the parent 34c2154

Dom.select("h1 + h2")

@dperini
Copy link
Owner

dperini commented May 14, 2024

@Fil ...
yes the last commit brings a regression within the changes made to improve and further isolate HTML / XML / XHTML languages inside "nwsapi" so next cut release will not contain this last namespaces related commit.
Hope no more regression will surface.
I understand developers need a "new stable nwsapi" release library and I will now focus on making that happen.
Thank you for the help.

@miguel-leon
Copy link

miguel-leon commented May 25, 2024

Just in case it helps, here's a more intricate case.
It's a different error, but I was getting 'not valid selector' before, so I guess it's related.

selector: ':is(.a, .b:not(.c:is(.d), .e), .f), .g'

stacktrace:

SyntaxError: unknown pseudo-class selector ':not(.c:is(.d'
    at emit (C:\Users\taliz\OneDrive\Escritorio\dev\puristic\node_modules\.pnpm\[email protected]\node_modules\nwsapi\src\nwsapi.js:576:17)
    at compileSelector (C:\Users\taliz\OneDrive\Escritorio\dev\puristic\node_modules\.pnpm\[email protected]\node_modules\nwsapi\src\nwsapi.js:1300:17)
    at compile (C:\Users\taliz\OneDrive\Escritorio\dev\puristic\node_modules\.pnpm\[email protected]\node_modules\nwsapi\src\nwsapi.js:766:16)
    at match_collect (C:\Users\taliz\OneDrive\Escritorio\dev\puristic\node_modules\.pnpm\[email protected]\node_modules\nwsapi\src\nwsapi.js:1371:16)
    at Object._matches [as match] (C:\Users\taliz\OneDrive\Escritorio\dev\puristic\node_modules\.pnpm\[email protected]\node_modules\nwsapi\src\nwsapi.js:1426:35)
    at Array.Resolver (eval at compile (C:\Users\taliz\OneDrive\Escritorio\dev\puristic\node_modules\.pnpm\[email protected]\node_modules\nwsapi\src\nwsapi.js:781:17), <anonymous>:3:104)
    at collect (C:\Users\taliz\OneDrive\Escritorio\dev\puristic\node_modules\.pnpm\[email protected]\node_modules\nwsapi\src\nwsapi.js:1578:21)
    at Object._querySelectorAll [as select] (C:\Users\taliz\OneDrive\Escritorio\dev\puristic\node_modules\.pnpm\[email protected]\node_modules\nwsapi\src\nwsapi.js:1533:36)

@dperini
Copy link
Owner

dperini commented May 25, 2024

@miguel-leon yes it is related ...
I almost fixed the spill. A mix up of wrong RegExps changes brought me here.
The ability of parsing nested selectors compounds was not the objective of "nwsapi", not now.
It will be available soon I hope, but not yet, not for a bug free release bug free at least,
but it has become the time to close this circle and push a working release.

The problem is known ... in this moment compiler generated code is not always up to the complexity of the task in term of nesting, levels deep. It has worked in "nwmatcher" why should it fail in "nwsapi" ? Well ... first because I missed up a particular parameter where the errors should be also parsed/evaluated by looping through alle the sub-nested exceptions.

I am working to push a commit for this failure only and see how this affects remaining problems.

@miguel-leon
Copy link

Oh. If the problem is RegExps, it's annoying because they lack recursion.
So also, in case it helps, you could decide and document that nesting is supported only up to a certain depth, and then repeat the expression inside of itself a couple of times to circumvent the recursion problem without using another mechanism outside the realm of regexps to loop through sub-nested cases.

For example for parenthesis:

  • Depth 1
\((?:[^)])*\)
  • Depth 2
\((?:\((?:[^)])*\)|[^)])*\)
  • Depth 4
\((?:\((?:\((?:\((?:[^)])*\)|[^)])*\)|[^)])*\)|[^)])*\)
  • Depth 8
\((?:\((?:\((?:\((?:\((?:\((?:\((?:\((?:[^)])*\)|[^)])*\)|[^)])*\)|[^)])*\)|[^)])*\)|[^)])*\)|[^)])*\)|[^)])*\)

✌️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants