Skip to content

fix: add namespace getter for type selectors#228

Merged
bartveneman merged 1 commit intomainfrom
fix/selector-namespace
May 3, 2026
Merged

fix: add namespace getter for type selectors#228
bartveneman merged 1 commit intomainfrom
fix/selector-namespace

Conversation

@bartveneman
Copy link
Copy Markdown
Member

feat: add namespace property to TypeSelector and UniversalSelector

Fixes the selector namespace API:

  • TypeSelector.name now always returns the local element name (e.g.
    'div' for both div and ns|div). Previously it returned the
    namespace prefix for namespaced selectors, making it impossible to
    get the element name without parsing .text manually.

  • UniversalSelector.name now always returns null. Previously it
    returned '*' for both plain * and *|*, making the two
    indistinguishable.

  • New namespace property on both types returns the namespace prefix:
    null (no qualifier), '' (empty, |div), 'ns' (named), or
    '*' (any-namespace wildcard).

Implementation: adds FLAG_HAS_NAMESPACE (bit 4 in the flags byte).
When set, content fields hold the local name and value fields hold the
namespace prefix. The flag distinguishes |div (empty namespace, flag
set, value length 0) from plain div (no qualifier, flag not set).

@codecov-commenter
Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 1.13kB (0.61%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
@projectwallace/css-parser-esm 185.51kB 1.13kB (0.61%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: @projectwallace/css-parser-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
node-types-DJytj0FB.d.ts (New) 23.63kB 23.63kB 100.0% 🚀
parse-selector.js 254 bytes 19.2kB 1.34%
css-node-C3t4b8Jt.js (New) 14.76kB 14.76kB 100.0% 🚀
node-types-CORQtdPo.d.ts (Deleted) -23.37kB 0 bytes -100.0% 🗑️
css-node-2WA1GE9K.js (Deleted) -14.14kB 0 bytes -100.0% 🗑️

Files in parse-selector.js:

  • ./src/parse-selector.ts → Total Size: 18.67kB

Files in css-node-C3t4b8Jt.js:

  • ./src/css-node.ts → Total Size: 14.54kB

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.86%. Comparing base (95e119a) to head (dd2d55c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #228      +/-   ##
==========================================
+ Coverage   93.83%   93.86%   +0.02%     
==========================================
  Files          17       17              
  Lines        2951     2965      +14     
  Branches      805      808       +3     
==========================================
+ Hits         2769     2783      +14     
  Misses        182      182              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bartveneman bartveneman merged commit ba3c31e into main May 3, 2026
5 checks passed
@bartveneman bartveneman deleted the fix/selector-namespace branch May 3, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants