fb55/css-select
a CSS selector compiler & engine
25 Releases
Latest: 3mo ago
v7.0.0Latest
π₯ Breaking Changes
- ESM only: the package now sets `"type": "module"`; CommonJS `require()` is only supported in modern environments [#1746](https://github.com/fb55/css-select/pull/1746)
- Minimum Node.js version is now 20.19.0
- Cleaned up deprecations
- Removed the deprecated `_compileToken` export. Use `_compileUnsafe` instead
- Removed the deprecated re-exports of `aliases`, `filters`, and `pseudos`. Use the `pseudos` option instead
- Removed `./package.json` subpath export
- `:enabled` now only matches form elements
β¨ New Features
- Added support for the `:lang()` pseudo-class
- Added support for *of* in `nth-*` pseudo-classes, e.g. `:nth-last-child(3n+2 of .a)`
- Full Changelog: https://github.com/fb55/css-select/compare/v6.0.0...v7.0.0
v6.0.0
π Changes
- Re-release of 5.2.0
- Switch to tshy, vitest & Biome (#1596) f7fd5fc
v5.2.1
~~The previous release was missing the `dist` directory.~~ Release 5.2.0 and 5.2.1 included breaking changes; 5.2.2 is a re-publish of 5.1.0 --- https://github.com/fb55/css-select/compare/v5.2.0...v5.2.1
v5.2.0
β¨ New Features
- Cache results for subtrees; vastly speeds up `:contains` and `:has` [#1025](https://github.com/fb55/css-select/pull/1025) β by @fb55
- Add support for `:read-only` and `:read-write` pseudos [#1497](https://github.com/fb55/css-select/pull/1497) β by @jed
- Improved support for large documents [#1132](https://github.com/fb55/css-select/pull/1132) β by @fb55
π Fixes
- Allow whitespace in `:empty` [#795](https://github.com/fb55/css-select/pull/795) β by @fb55
- Filter queried elements inside template element [#981](https://github.com/fb55/css-select/pull/981) β by @andolf
- Handle template tags in `selectOne` [#1001](https://github.com/fb55/css-select/pull/1001) β by @fb55
β¨ New Contributors
- @andolf made their first contribution in https://github.com/fb55/css-select/pull/981
- @EFord36 made their first contribution in https://github.com/fb55/css-select/pull/1107
- @jed made their first contribution in https://github.com/fb55/css-select/pull/1497
- Full Changelog: https://github.com/fb55/css-select/compare/v5.1.0...v5.2.0
v5.1.0
π Changes
- Added an option to disable relative selectors (#766) 1c1f7f2
- By default, selectors are relative to the passed `context`, which means that no parent elements of the context will be matched. (Eg. `a b c` with context `b` will never give any results.)
- See https://github.com/fb55/css-select/issues/709 for context.
v5.0.1
π Changes
- fix: Previously, some options weren't properly passed on to sub-selectors such as `:is(...)` or `:not(...)`. (#758) 77945c4
v5.0.0
π₯ Breaking
- `domhandler`'s node types have changed. Some of these changes were inherited by `css-select` #754
- `css-select` is now a dual CJS and ESM package #756
- Deep imports are no longer permitted
- Throw an error for `:host-context` #755
- The error message for unknown pseudo classes has changed.
β¨ Features
- Added a `pseudos` option #757
- This option allows users to specify pseudo-classes.
- Extending `filters`, `pseudos` and `aliases` is now deprecated.
- https://github.com/fb55/css-select/compare/v4.3.0...v5.0.0
v4.3.0
π What's Changed
- feat: Upgrade to css-what@6, add quirks mode option by @fb55 in https://github.com/fb55/css-select/pull/657
- In quirks mode, `.class` and `#id` selectors are case-insensitive.
- feat: Add optional `prevElementSibling` adapter method by @fb55 in 78776e8
- fix: Throw errors for namespaced selectors by @fb55 in 255e965
- Namespaced selectors (eg. `*|div`, `[foo|bar]` already caused errors before this release. We now parse them properly and throw errors with better descriptions.
- Full Changelog: https://github.com/fb55/css-select/compare/v4.2.1...v4.3.0
v4.2.1
π Changes
- fix: Don't add siblings multiple times in `appendNextSiblings` (#656) 726f51b
- docs: Improve README e8974a3
v4.2.0
π What's Changed
- chore(ci): Switch to GitHub Actions by @fb55 in https://github.com/fb55/css-select/pull/493
- feat: Add support for `:where` pseudo class as alias for `:is` by @jannispl in https://github.com/fb55/css-select/pull/582
β¨ New Contributors
- @lrosemberg made their first contribution in https://github.com/fb55/css-select/pull/489
- @jannispl made their first contribution in https://github.com/fb55/css-select/pull/582
- Full Changelog: https://github.com/fb55/css-select/compare/v4.1.3...v4.2.0
v4.1.3
π Changes
- `compile`'s return value type was updated to `Node`, instead of an `Element` (more types can now be passed). 1419455
- Bump `css-what` from 5.0.0 to 5.0.1, fixing potentially expensive regex (#451) e3f4cf1
- Use `@types/boolbase` 636c238
v4.1.2
π Changes
- fix(types): Fixed last `context` types e15cc53
v4.1.1
π Changes
- fix(types): Fix `context` types not being updated everywhere d2b0409
v4.1.0
π Changes
- Allow plain nodes as context (#424) 58109d6
- Allow parsed selectors to be passed directly to functions (#418) 01afada
v4.0.0
π Changes
- Aliases are a new way to write pseudos (#403) 206535e
- It is now possible to write a pseudo selector that shortens a longer selector as an alias. Have a look at #403 for examples.
- __BREAKING:__ Several built-in pseudos are now stricter. This aligns them with the CSS spec, but might lead to changes in results.
- Upgraded to `css-what@5.0.0`
- Added support for the `s` flag in attribute selectors.
- __BREAKING:__ In HTML, attributes are now automatically considered case-insensitive, based on the HTML spec. Some selectors might now match more elements.
- Fix `!=` ignoring elements without attribute (#402) 4484259
- __BREAKING:__ Removed `strict` option 9329fb8
- + 1 more
v3.1.2
π Changes
- fix: Ensure parent elements are tags efcfcdb
- Now that parent elements can also be documents, this fixes some edge-cases.
- bump domutils from 2.4.2 to 2.4.4 b141d76
v3.1.1
π Changes
- Support DOM elements of type `root` in the `:root` pseudo-selector c4d2b7b
- bump domutils, domhandler & htmlparser2 (#312) c4d2b7b
- bump nth-check from 1.0.2 to 2.0.0 187c9cd
- bump css-what from 3.4.1 to 4.0.0 4241106
v3.1.0
π Changes
- feat(index): Export `prepareContext` function f997165
- feat(general): Add `cacheResults` option 6db3de6
- fix(general): Fix descendant cache issue 0c0a8ff
- refactor(tests): Remove positional, fix attribute tests for Sizzle spec b8ae895
v3.0.4
π Changes
- Bump css-what, add domhandler as dep cbb7187
- Run prettier in check mode before passing tests 8bd03e8
- Update funding information 3242963
v3.0.3
π Changes
- Fix `types` entry in `package.json`
v3.0.2
π Changes
- Fixed an issue where the previous release didn't include built assets (reported in #229)
- Ported tests to Jest & TS
v3.0.1
π Changes
- Port all shipped code to TypeScript, identifying several inconsistencies along the way
- __BREAKING:__ The module exports an object now, which includes a `default` property. If you used the exported function before, you will have to update your code.
- Use `adapter.equals` across the codebase
- __BREAKING:__ The signature for pseudos has changed. The second argument is now the `options` object, not the adapter anymore. To update your code, extract the adapter from the options object, eg. `pseudos.custom = (elem, adapter) => {}` is now `pseudos.custom = (elem, {adapter}) => {}`.
- Implement `:any-link`
- Support traversal-first `:has` (fixes #111)
v3.0.0
_Released with a breaking bug, please ignore._
v2.1.0
π Changes
- Add `pseudos` that depend on optional Adapter APIs (#139, @jaspreet57)
- fix: :scope not matching when selecting in a scope (#154, @eps1lon)
- Bump css-what to 3.2.1
v2.0.0
π Changes
- Improves scope support (thanks to @Delgan, from 2015 π¨) β #37, #38, #43
- Allows users to pass a DOM adapter (thanks to @nrkn, from 2016 π¬) β #66
- Change since 1.3.0-rc0 (#101): Adapters are now passed in `options`, which results in two breaking changes: First, pseudo selectors now take the adapter as the second argument, and arguments as the third. Second, filters arenβt checked anymore if they have the required number of arguments.
- Exponential time querying fix (thanks to @dbuezas); requires a modern JS environment β #94, #100
- And a pretty complicated domutils upgrade (thanks to @chriseppstein) β #96
- Throws regular errors instead of syntax errors when the selector is faulty (inherited from css-what)
