Skip to content

Can't use parent-sensitive pseudoselectors with :not #5

Closed
@apaleslimghost

Description

@apaleslimghost

Initial checklist

Affected packages and versions

[email protected]

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions