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

Support :scope pseudo-class selector #97

Open
0kku opened this issue May 10, 2022 · 5 comments
Open

Support :scope pseudo-class selector #97

0kku opened this issue May 10, 2022 · 5 comments
Labels
enhancement New feature or request upstream

Comments

@0kku
Copy link
Collaborator

0kku commented May 10, 2022

https://developer.mozilla.org/en-US/docs/Web/CSS/:scope

const doc = new DOMParser().parseFromString("<div></div>", "text/html");

doc.querySelector(":scope"); // should return <html> element of the document, but returns null
@0kku 0kku added the enhancement New feature or request label May 10, 2022
@b-fuze
Copy link
Owner

b-fuze commented May 12, 2022

A repro of Element.querySelector[All](":scope > foo")

import { DOMParser } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";
const doc = new DOMParser().parseFromString(
  `
    <div>
      <div class=outer>
        <div class=inner></div>
      </div>
      <div class=other-outer></div>
    </div>
  `,
  "text/html",
);

const parent = doc.querySelector("div");
console.log(
  [...parent.querySelectorAll(":scope > div")].map((d) => d.className),
);

Produces the following incorrect output with Deno DOM/nwsapi:

[ "outer", "inner", "other-outer" ]

When it's supposed to look like (when e.g. run in a standards-compliant browser)

[ "outer", "other-outer" ]

@jsejcksn
Copy link

@b-fuze I was going to follow up about this today since it was reported to be fixed in nwsapi, but I see you already wrote a message about it in another issue. If there are any blockers other than updating dependencies, can you share them here?

@b-fuze
Copy link
Owner

b-fuze commented Aug 17, 2023

Hey @jsejcksn, thanks for the reminder. I got quite busy and forgot, but I'll make some time tomorrow to update NWSAPI and check if #139 will also be resolved.

@b-fuze
Copy link
Owner

b-fuze commented Aug 18, 2023

Okay, I have just tested the latest version of NWSAPI (2.2.7) and... the bug is still there. NWSAPI uses this makeref function for :scope selectors which naively relies on an element to have uniquely identifying elements like a combination of classnames and/or IDs. I submitted a new issue about it: dperini/nwsapi#96

Unfortunate 😔

@jsejcksn
Copy link

@b-fuze Thanks for the update and the link so that we can subscribe to follow along!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request upstream
Projects
None yet
Development

No branches or pull requests

3 participants