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 :has pseudo class #139

Open
cderv opened this issue Jul 3, 2023 · 3 comments
Open

Support :has pseudo class #139

cderv opened this issue Jul 3, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@cderv
Copy link

cderv commented Jul 3, 2023

This is about the pseudo class :has (https://developer.mozilla.org/en-US/docs/Web/CSS/:has#specifications) which currently return a DOMException

import { DOMParser, Element } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";
const doc = new DOMParser().parseFromString(
  `
  <h1>Hello World!</h1>
  <p>Hello from <a href="https://deno.land/">Deno!</a></p>
`,
  "text/html",
);
const p = doc.querySelector("p");
const p2 = doc.querySelector("p:has(a)");
// returns Uncaught DOMException

The above works in JS in browser console.

Possibly still early maybe as it requires some flags in some versions of browsers (https://caniuse.com/css-has) but still interesting feature.

@0kku 0kku added the enhancement New feature or request label Jul 5, 2023
@b-fuze
Copy link
Owner

b-fuze commented Jul 6, 2023

I'll have to check if our upstream dependency NWSAPI has implemented it already; I think that they have and I need to vendor their newer release anyways since it fixes some long standing bugs (e.g. :scope)

@oles
Copy link

oles commented May 30, 2024

:has usage is becoming more and more common now - I'd love to see support for :has for deno-dom ❤️

@b-fuze
Copy link
Owner

b-fuze commented May 30, 2024

Yeah, me too tbh. The problem currently is that nwsapi has bugs in its :has selector implementation... And while I'm interested in other engines like css-select from NPM I do not like the non trivial drop in performance that would result from that... So currently I'm thinking of forking nwsapi for deno-dom and fixing it myself and maybe the nwsapi authors can upstream my changes or fix it in the way they prefer when they get the time and then I can decommission the fork

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

No branches or pull requests

4 participants