diff --git a/.eslintrc.yml b/.eslintrc.yml
deleted file mode 100644
index 570fefd..0000000
--- a/.eslintrc.yml
+++ /dev/null
@@ -1,123 +0,0 @@
-env:
- amd: true
- browser: true
- commonjs: true
-
-rules:
- accessor-pairs: 2
- array-callback-return: 2
- block-scoped-var: 0
- class-methods-use-this: 2
- complexity: 0
- consistent-return: 2
- curly: 0
- default-case: 2
- dot-location: 2
- dot-notation: 0
- eqeqeq: 2
- for-direction: 2
- getter-return: 2
- guard-for-in: 0
- init-declarations: 0
- no-alert: 2
- no-await-in-loop: 2
- no-caller: 2
- no-case-declarations: 2
- no-catch-shadow: 2
- no-compare-neg-zero: 2
- no-cond-assign: 2
- no-console: 0
- no-constant-condition: 2
- no-control-regex: 0
- no-debugger: 2
- no-delete-var: 2
- no-div-regex: 2
- no-dupe-args: 2
- no-dupe-keys: 2
- no-duplicate-case: 2
- no-else-return: 2
- no-empty-character-class: 2
- no-empty-function: 2
- no-empty-pattern: 2
- no-empty: 2
- no-eq-null: 2
- no-eval: 2
- no-ex-assign: 2
- no-extend-native: 2
- no-extra-bind: 2
- no-extra-boolean-cast: 2
- no-extra-label: 2
- no-extra-parens: 2
- no-extra-semi: 2
- no-fallthrough: 2
- no-floating-decimal: 2
- no-func-assign: 2
- no-global-assign: 2
- no-implicit-coercion: 2
- no-implicit-globals: 2
- no-implied-eval: 2
- no-inner-declarations: 2
- no-invalid-regexp: 2
- no-invalid-this: 2
- no-irregular-whitespace: 2
- no-iterator: 2
- no-label-var: 2
- no-labels: 2
- no-lone-blocks: 2
- no-loop-func: 2
- no-magic-numbers: 0
- no-multi-spaces: 2
- no-multi-str: 2
- no-new-func: 0
- no-new-wrappers: 2
- no-new: 2
- no-obj-calls: 2
- no-octal-escape: 2
- no-octal: 2
- no-param-reassign: 0
- no-proto: 0
- no-prototype-builtins: 2
- no-redeclare: 2
- no-regex-spaces: 2
- no-restricted-globals: 2
- no-restricted-properties: 2
- no-return-assign: 2
- no-return-await: 2
- no-script-url: 2
- no-self-assign: 2
- no-self-compare: 2
- no-sequences: 2
- no-shadow-restricted-names: 2
- no-shadow: 0
- no-sparse-arrays: 2
- no-template-curly-in-string: 2
- no-throw-literal: 2
- no-undef-init: 2
- no-undef: 2
- no-undefined: 0
- no-unexpected-multiline: 2
- no-unmodified-loop-condition: 2
- no-unreachable: 2
- no-unsafe-finally: 2
- no-unsafe-negation: 2
- no-unused-expressions: 0
- no-unused-labels: 2
- no-unused-vars: 2
- no-use-before-define: 0
- no-useless-call: 2
- no-useless-concat: 2
- no-useless-escape: 2
- no-useless-return: 2
- no-void: 2
- no-warning-comments: 2
- no-with: 2
- prefer-promise-reject-errors: 2
- radix: 2
- require-await: 2
- strict: 0
- use-isnan: 2
- valid-jsdoc: 2
- valid-typeof: 2
- vars-on-top: 0
- wrap-iife: 0
- yoda: 2
diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml
index 0873017..7cf62dc 100644
--- a/.github/workflows/node.js.yml
+++ b/.github/workflows/node.js.yml
@@ -3,26 +3,42 @@ name: nwsapi
on:
push:
branches:
- - main
+ - master
pull_request:
branches:
- - main
+ - master
jobs:
- build:
+ test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v7
+
+ - name: Setup pnpm
+ uses: pnpm/action-setup@v6
- name: Setup Node.js
- uses: actions/setup-node@v2
+ uses: actions/setup-node@v7
with:
- node-version: '14'
+ node-version: '24'
+ cache: pnpm
- name: Install dependencies
- run: npm install
+ run: pnpm install --frozen-lockfile
+
+ - name: Lint
+ run: pnpm run lint
+
+ - name: Clone upstream test suites (sparse + shallow)
+ run: pnpm run upstream:clone
+
+ - name: Verify upstream pins
+ run: pnpm run upstream:verify
+
+ - name: Install Playwright browsers
+ run: pnpm exec playwright install --with-deps chromium
- name: Run tests
- run: npm testIs the NodeJS yaml configuration needed in my "nwsapi" repository ?
+ run: pnpm test
diff --git a/.gitignore b/.gitignore
index 5be2eea..2d1ec32 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,14 @@
node_modules/
package-lock.json
yarn.lock
+
+# pristine upstream checkouts (pin of record lives in .gitmodules)
+# anchored to repo root so test/upstream/ stays tracked
+/upstream/
+
+# playwright artifacts
+test-results/
+playwright-report/
+
+# build output
+dist/nwsapi.min.js
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..a1d05f7
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,11 @@
+# wpt-7aed663 sha256:9954c30501783f0c12ea5026a94cf988c8c5d2ac3ed51279cbfdd7476f92c393
+[submodule "upstream/wpt"]
+ ignore = dirty
+ ref = 7aed6630812b20e6eec2a2e40594f8dfda036e00
+ path = upstream/wpt
+ url = https://github.com/web-platform-tests/wpt.git
+ branch = master
+ shallow = true
+ sparse-checkout = resources common dom/nodes css/selectors
+ verify = pnpm run test:upstream
+# no-release-tag: web-platform-tests publishes no release tags; pinned by ref on master
diff --git a/README.md b/README.md
index dd25e01..8985a69 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
Fast CSS Selectors API Engine
-   
+   
NWSAPI is the development progress of [NWMATCHER](https://github.com/dperini/nwmatcher) aiming at [Selectors Level 4](https://www.w3.org/TR/selectors-4/) conformance. It has been completely reworked to be easily extended and maintained. It is a right-to-left selector parser and compiler written in pure Javascript with no external dependencies. It was initially thought as a cross browser library to improve event delegation and web page scraping in various frameworks but it has become a popular replacement of the native CSS selection and matching functionality in newer browsers and headless environments.
@@ -10,8 +10,8 @@ It uses [regular expressions](https://en.wikipedia.org/wiki/Regular_expression)
## Installation
-To include NWSAPI in a standard web page:https://ko-fi.com/dperini
-Support & Sponsoring
+To include NWSAPI in a standard web page:
+
```html
```
@@ -29,20 +29,19 @@ $ npm install nwsapi
```
NWSAPI currently supports browsers (as a global, `NW.Dom`) and headless environments (as a CommonJS module).
-Support & Sponsoring
-
-NWSAPI is an open-source project created and maintained with dedication. If you use this library in your apps, headless environments, or frameworks, please consider supporting its ongoing development!
-
- GitHub Sponsors: Sponsor monthly tiers directly through GitHub.
- Buy Me a Coffee: Make a one-time tip or contribution.
-
-Your support helps cover development time, maintain full conformance with W3C Selectors specifications, and keep NWSAPI fast and dependency-https://ko-fi.com/dperinifree.
-Support & Sponsoring
## Supported Selectors
Here is a list of all the CSS2/CSS3/CSS4 [Supported selectors](https://github.com/dperini/nwsapi/wiki/CSS-supported-selectors).
+State pseudo-classes from [Selectors Level 4](https://www.w3.org/TR/selectors-4/):
+
+* `:open` — matches ``/`