Skip to content

Add getElementsByClassName to the DOM polyfill - #625

Open
airhorns wants to merge 1 commit into
Shopify:mainfrom
airhorns:polyfill-get-elements-by-class-name
Open

Add getElementsByClassName to the DOM polyfill#625
airhorns wants to merge 1 commit into
Shopify:mainfrom
airhorns:polyfill-get-elements-by-class-name

Conversation

@airhorns

Copy link
Copy Markdown

What changed

Remote code is commonly type-checked against lib.dom, but document.getElementsByClassName() and element.getElementsByClassName() are missing at runtime from @remote-dom/polyfill. This adds both standard hosts (deliberately not DocumentFragment) and returns matches in tree order.

The lookup tokenizes ASCII whitespace, requires every requested class, removes duplicate search tokens, and compares class names literally. It does not build a CSS selector, so class names containing selector punctuation such as . and : work correctly.

The returned value follows the polyfill's existing concrete NodeList collection model. Live HTMLCollection behavior remains a separate compatibility concern, as it does in #620.

Validation

  • pnpm exec vitest run (179 tests)
  • pnpm lint
  • pnpm type-check
  • mise exec node@20.20.0 -- pnpm --filter @remote-dom/polyfill build

@airhorns
airhorns force-pushed the polyfill-get-elements-by-class-name branch 2 times, most recently from 4ebbda6 to 9b7d4e5 Compare July 28, 2026 14:19
Assisted-By: devx/ca2f43ab-bbf9-4273-b1bc-0b06f8c90a57
@airhorns
airhorns force-pushed the polyfill-get-elements-by-class-name branch from 9b7d4e5 to c281215 Compare July 28, 2026 14:20
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