Skip to content

fix(cli): preserve stylesheet order during website capture - #5311

Open
user-github-me wants to merge 1 commit into
heygen-com:mainfrom
user-github-me:fix/capture-stylesheet-cascade
Open

user-github-me wants to merge 1 commit into
heygen-com:mainfrom
user-github-me:fix/capture-stylesheet-cascade

Conversation

@user-github-me

@user-github-me user-github-me commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What

Preserve stylesheet order and media conditions when website capture inlines linked CSS into the saved page.

Why

Capture appends fetched CSS after the page's existing styles and removes the original link. A blue hero whose inline override follows a red linked theme therefore turns red in both the live page and extracted/page.html. A print-only stylesheet also becomes screen styling.

Related work

#284 introduced the website capture pipeline, and #3726 established the fetch user agent used here. #4685 concerned core composition bundling; this correction is confined to website capture's independent HTML extractor. No open issue or competing implementation was found in the current PR inventory.

How

Replace each fetched stylesheet link at its existing DOM position, carrying its media value into the replacement style. The extractor only requires the page's evaluate and URL methods. Existing relative asset URL resolution and failed-fetch behavior remain covered by controls.

Test plan

  • Eight extractor tests cover a later override, interleaved stylesheets, repeated URLs, media preservation, existing stylesheet precedence, HTTP and network failures, and relative CSS assets. The initial four regressions fail on current main with four controls passing.
  • All 13 tests pass across HTML extraction, core extraction, extracted-script filtering and post-extraction handling.
  • Actual Chrome 152 reproduction uses intercepted fixture responses and the real extractor. Main changes three screen-color cases and activates a print-only stylesheet on screen; fixed source preserves the original computed colors and screenshot pixels in the live page and saved HTML for all four cases. Print mode still applies the print stylesheet.
  • Full workspace build, CLI build and typecheck, root lint, changed-file lint and formatting, test reachability and normal commit hooks pass. Fallow reports no issues in the changed files; it emits warnings for inherited suppression kinds.
  • Comment citation and comment-share checks pass.

CI verification (2026-10-09): all 81 latest checks on signed head f109740caecf06933ce09909367426e8223002bb have completed: 68 successful and 13 skipped. This includes build, tests, CodeQL, Windows render verification, and regression checks.

This branch has not been deployed

No deployments
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.

1 participant