Skip to content

fix(site-import): drop repeated site-wide inline rules after the first page - #562

Open
tommy230 wants to merge 1 commit into
CoreBunch:mainfrom
tommy230:fix/site-import-repeated-inline-rules
Open

tommy230 wants to merge 1 commit into
CoreBunch:mainfrom
tommy230:fix/site-import-repeated-inline-rules

Conversation

@tommy230

Copy link
Copy Markdown
Contributor

Summary

Many sites print the same <style> block into every page's head. A site import added one copy of those rules per page to the global sheet. The later copies then beat a page's own override at equal specificity, so that page's override lost.

<!-- every page -->   <style>.nav a{color:#fff}</style>
<!-- one page only --> <style>.menu a{color:#1e1e1e}</style>

In a browser that page's link is near-black. After import, later pages' white copies land after the override, so it turns white.

The fix:

  • Keeps the first copy of a rule and drops byte-identical repeats from later pages' inline CSS.
  • Leaves linked stylesheets alone, and keeps repeats within one page.
  • Keys rules with relative url() by page directory, so the same text in different folders stays distinct.

This assumes a page prints the site-wide block before its own rules, as themes do. A page that prints its own rule before the site-wide block would now have that rule win, where a browser lets the site-wide block win. It does not help when a page overrides the exact same selector, since the importer merges those into one rule that no longer matches the site-wide copy.

Verification

  • bun run build
  • bun run lint
  • bun test: 7058 pass, 0 fail
  • Docker/deployment check, if relevant: not relevant

New tests in src/__tests__/siteImport/inlineRuleDedupe.test.ts fail on main and pass with this change.

Checklist

  • Tests cover behavior changes.
  • Docs were updated when behavior, config, deployment, or public surfaces changed.
  • No compatibility shim was added for old pre-release behavior.
  • No secrets, local databases, uploads, or generated artifacts are included.

🤖 Generated with Claude Code

…t page

Each page's inline <style> CSS is parsed as its own source, so a block
every page prints landed in the global sheet once per page. The later
copies then outranked one page's own override at equal specificity. Keep
the first copy, drop byte-identical repeats from later pages' inline
sources, and renumber the survivors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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