syntax-tree / hast-util-select

utility to add `querySelector`, `querySelectorAll`, and `matches` support for hast

Home Page:https://unifiedjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't use parent-sensitive pseudoselectors with :not

apaleslimghost opened this issue · comments

Initial checklist

Affected packages and versions

hast-util-select@7.0.0

Link to runnable example

https://runkit.com/quarterto/6397058cb17f2300086ba513

Steps to reproduce

import {h} from 'hastscript'
import {selectAll} from 'hast-util-select'

selectAll('img:not(:first-child)`, h('body', [
    h('img', { src: 'https://example.com/one' }),
    h('p', ['text']),
    h('img', { src: 'https://example.com/two' }),
]))

Expected behavior

it selects the second img

Actual behavior

Error: Cannot use `:first-child` without parent

this is because :not is implemented using matches, which doesn't support parent-sensitive pseudos

Affected runtime and version

node@14, node@16

Affected package manager and version

No response

Affected OS and version

No response

Build and bundle tools

No response

commented

Ah, interesting.
Want to work on a PR?

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.