{"id":25141,"library":"css-select-umd","title":"css-select","description":"A CSS selector compiler/engine that turns CSS selectors into functions for testing and querying DOM elements. Current stable version is 2.x (v1.3.0-rc0 is a pre-release of a UMD build). It uses right-to-left execution for efficient O(n) performance, unlike left-to-right engines like Sizzle. Features full CSS3 selectors, partial jQuery extensions, and uses domhandler/domutils as default DOM adapter. Released regularly via npm; TypeScript types included since v1.3.0. Key differentiator: performance through right-to-left compilation and a function-stack approach.","status":"active","version":"1.3.0-rc0","language":"javascript","source_language":"en","source_url":"git://github.com/matt-gadd/css-select","tags":["javascript","css","selector","sizzle","typescript"],"install":[{"cmd":"npm install css-select-umd","lang":"bash","label":"npm"},{"cmd":"yarn add css-select-umd","lang":"bash","label":"yarn"},{"cmd":"pnpm add css-select-umd","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for default DOM structure used by css-select","package":"domhandler","optional":false},{"reason":"Default adapter for DOM operations","package":"domutils","optional":false},{"reason":"CSS selector parser used internally","package":"css-what","optional":false}],"imports":[{"note":"ESM default import; for CommonJS use require('css-select-umd') but the UMD build also supports global scope.","wrong":"const CSSselect = require('css-select-umd')","symbol":"CSSselect","correct":"import CSSselect from 'css-select-umd'"},{"note":"selectOne is a named export; do not access as a method of default import.","wrong":"import CSSselect from 'css-select-umd'; CSSselect.selectOne(...)","symbol":"selectOne","correct":"import { selectOne } from 'css-select-umd'"},{"note":"compile is a named export; available as a side-effect of importing the package.","wrong":"const compile = require('css-select').compile","symbol":"compile","correct":"import { compile } from 'css-select-umd'"}],"quickstart":{"code":"import CSSselect from 'css-select-umd';\nimport { DomHandler } from 'domhandler';\nimport { parseDocument } from 'htmlparser2';\n\nconst html = '<div><p class=\"foo\">Hello</p><p class=\"bar\">World</p></div>';\nconst handler = new DomHandler((err, dom) => {\n  if (err) throw err;\n  const elements = CSSselect('p.foo', dom);\n  console.log(elements.length); // 1\n  console.log(elements[0].children[0].data); // 'Hello'\n});\nparseDocument(html, handler);","lang":"typescript","description":"Shows how to import and use css-select-umd to query DOM elements from parsed HTML using htmlparser2."},"warnings":[{"fix":"Use stable version 2.x instead or pin to exact pre-release version.","message":"Version 1.3.0-rc0 is a pre-release of a UMD build; API may change before stable release.","severity":"breaking","affected_versions":"1.3.0-rc0"},{"fix":"Import from 'css-select-umd' or from 'css-select' if not using UMD.","message":"The package name is 'css-select-umd' but exports are identical to 'css-select' UMD build; ensure you use correct import path.","severity":"gotcha","affected_versions":">=1.3.0-rc0"},{"fix":"Upgrade to css-select v2+ for latest API and use 'css-select' package directly instead of UMD bundle if possible.","message":"Older versions (<2.0) of the underlying 'css-select' used a different API; 'css-select-umd' is based on v1 branch and may not have newer features.","severity":"deprecated","affected_versions":"<1.3.0"},{"fix":"Wrap selector calls in try-catch or validate selectors before passing to CSSselect.","message":"CSSselect throws errors on invalid selectors; this differs from jQuery which silently ignores them.","severity":"gotcha","affected_versions":">=1.0"}],"env_vars":null,"search_vec":"'2':24 'adapt':69 'approach':93 'build':35 'compil':87 'compiler/engine':7 'css':2,5,10,95 'css-select':1 'css3':58 'current':20 'default':67 'differenti':80 'dom':18,68 'domhandler/domutils':65 'effici':44 'element':19 'engin':53 'execut':42 'extens':62 'featur':56 'full':57 'function':13,91 'function-stack':90 'includ':76 'javascript':94 'jqueri':61 'key':79 'left':41,50,86 'left-to-right':49 'like':54 'n':46 'npm':73 'o':45 'partial':60 'perform':47,81 'pre':30 'pre-releas':29 'queri':17 'regular':71 'releas':31,70 'right':39,52,84 'right-to-left':38,83 'select':3 'selector':6,11,59,96 'sinc':77 'sizzl':55,97 'stabl':21 'stack':92 'test':15 'turn':9 'type':75 'typescript':74,98 'umd':34 'unlik':48 'use':37,64 'v1.3.0':78 'v1.3.0-rc0':26 'version':22 'via':72 'x':25","created_at":"2026-05-01T13:43:13.321053+00:00","updated_at":"2026-05-01T13:43:13.321053+00:00","problems":[{"fix":"Use 'import CSSselect from 'css-select-umd'' or 'const CSSselect = require('css-select-umd').default'","cause":"Using CommonJS require on an ESModule default export without proper interop.","error":"TypeError: CSSselect is not a function"},{"fix":"Install domhandler: npm install domhandler","cause":"Missing peer dependency domhandler which is required for default DOM structure.","error":"Cannot find module 'domhandler'"},{"fix":"Ensure you pass a valid DOM tree (e.g., from domhandler) and that elements have a 'type' property.","cause":"Passing a non-DOM element or invalid DOM node to CSSselect.","error":"TypeError: Cannot read properties of undefined (reading 'type')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/matt-gadd/css-select","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/css-select-umd","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}