ReviewOS

home-lang/home

Complete Workerd HTMLRewriter comment and selector compatibility

#198
Closed chris opened this 9 days ago ·
9 days ago

Tracks the remaining packages/runtime/test/bun-corpus/js/workerd bootstrap/native parity after the initial JavaScript corpus pass.

Current exact directory result:

  • 3 files discovered/executed
  • 2 tests passed
  • 1 test failed
  • 0 tests unsupported
  • 1 intentional Debug-only todo

The remaining html-rewriter.test.js now executes through:

  • sync and async handler error propagation
  • string/Response/ArrayBuffer inputs
  • deferred async response replacement
  • ordered attribute iteration
  • iterator detachment after callback return and attribute mutation
  • element mutation methods
  • class handler receiver identity

Its next failure is document/element comment mutation support. After comments, complete the selector matrix (structural, class/id, attribute operators, descendants), element metadata, and streaming cases without delegating to bun test.

Parent tracking: #66

9 days ago

Published 4fdaabf80 to main with the next Workerd/HTMLRewriter parity tranche.

Implemented in the bootstrap corpus path:

  • mixed default + named import lowering and timers/promises.setImmediate
  • correct debug-mode exposure through the Bun harness
  • Response/HTMLRewriter Symbol validation
  • document text/end callbacks and async handler error propagation
  • deferred async element replacement
  • ordered attribute iteration, post-callback detachment, and mutation invalidation
  • element before/prepend/append/after/replace/remove/removeAndKeepContent/setInnerContent mutations
  • handler receiver identity

Focused verification against the fully linked test binary:

  • the new mixed-import unit test passes
  • existing Response and all three HTMLRewriter smoke/error unit tests pass
  • the exact Workerd range (files 4235–4237 of 4708) executes without the former native crash and now reaches one remaining failure: HTMLRewriter: handles comment mutations

The next implementation boundary remains comment callbacks/mutations, then selector semantics, element metadata, and streaming behavior. #199 tracks making lol-html linkage self-contained rather than optional.

9 days ago

Comment-handler tranche published to main in 8f16987a4.

This adds element-scoped and document-scoped comment callbacks with text/removed properties plus before/after/replace/remove mutation and HTML-vs-escaped insertion semantics. A dedicated regression covering both scopes passes.

Re-running Workerd files 4235–4237 on the newly linked test binary now passes the upstream comment mutation and property cases; the sole failure advances to selector tests (* is the first unsupported selector behavior). Continuing there next.

9 days ago

Selector/metadata tranche published to main in b02a5d1f6.

Implemented and regression-covered:

  • wildcard, tag, class, ID, attribute presence/value/operator/case selectors
  • nth-child, first-child, nth-of-type, first-of-type, and not(:first-child)
  • descendant and direct-child combinators
  • parsed element ancestry/sibling/type position tracking
  • text chunk lastInTextNode
  • element selfClosing and canHaveContent metadata, including void and SVG behavior

The focused selector, metadata, and comment regressions all pass. The exact Workerd range now clears selector, deletion, metadata, and subsequent regression cases; its sole failure advances to HTTP payload decoding at works with http fetch using /gzip (plain / already passes). Continuing with gzip/chunked/file response bodies next.

9 days ago

Completed and pushed in b1cb50663 (feat(runtime): stream html rewriter responses).

The Home bootstrap now supports deferred/pull-driven HTMLRewriter response bodies, strips stale content encoding/length after transformation, preserves response metadata, handles compressed Workerd fixture responses, and carries the transformed output through a reader-backed Response.

Verification on the freshly linked Home test binary:

  • focused deferred gzip + pull-stream regression: pass
  • focused text/metadata regression: pass
  • focused selector regression: pass
  • exact js/workerd range (HOME_BUN_CORPUS_START=4235, HOME_BUN_CORPUS_LIMIT=3): pass, zero failures

This completes the remaining Workerd HTMLRewriter comments, selectors, metadata, mutation, error propagation, HTTP/HTTPS, gzip, chunked, file, payload, and streaming compatibility tracked here. Parent: #66.

9 days ago

Closing as completed by b1cb50663; the exact three-file Workerd corpus range is green in Home.

Sign in to comment on this issue.