Skip to content

refactor(core): route ReSpec's own style injection through insertStyle - #5447

Merged
marcoscaceres merged 5 commits into
mainfrom
refactor/core-insert-style
Sep 5, 2026
Merged

refactor(core): route ReSpec's own style injection through insertStyle#5447
marcoscaceres merged 5 commits into
mainfrom
refactor/core-insert-style

Conversation

@marcoscaceres

Copy link
Copy Markdown
Contributor

ReSpec injected its own stylesheets from fifteen different places, each hand-rolling createElement("style") or an html template, including two near-identical local insertStyle helpers in core/style.js and core/ui.js. This routes them all through one core/insert-style.js with no behavior change, verified by rendering the same spec with both bundles and diffing the resulting head: 31 children and 13 style elements, identical in id, class attribute, order and content.

@marcoscaceres marcoscaceres added the AI Contains AI-generated logic; see AI_POLICY.md label Sep 2, 2026
@marcoscaceres
marcoscaceres force-pushed the refactor/core-insert-style branch from 6d2ac24 to 1146b90 Compare September 2, 2026 11:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The helper can insert ReSpec styles outside the document head when given a non-head anchor.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Centralizes ReSpec stylesheet injection through a shared helper.

Changes:

  • Adds insertStyle() for consistent style creation and placement.
  • Migrates 15 core modules to the helper.
  • Preserves IDs, classes, CSS content, and ordering.
File summaries
File Description
src/core/insert-style.js Adds shared style insertion helper.
src/core/algorithms.js Uses shared helper.
src/core/caniuse.js Preserves stylesheet metadata.
src/core/cddl.js Centralizes anchored insertion.
src/core/data-type.js Centralizes style injection.
src/core/dfn-index.js Centralizes style injection.
src/core/dfn-panel.js Centralizes anchored insertion.
src/core/examples.js Centralizes anchored insertion.
src/core/highlight-vars.js Centralizes style injection.
src/core/highlight.js Replaces templated style creation.
src/core/implementation-status.js Preserves stylesheet metadata.
src/core/issues-notes.js Centralizes anchored insertion.
src/core/mdn-annotation.js Centralizes style injection.
src/core/style.js Removes its local helper.
src/core/ui.js Removes its local helper.
src/core/webidl.js Centralizes anchored insertion.
Review details
  • Files reviewed: 16/16 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/core/insert-style.js Outdated
@marcoscaceres

Copy link
Copy Markdown
Contributor Author

Reviewed locally and here. I'm happy with this. It's a good little cleanup.

@marcoscaceres
marcoscaceres merged commit 54a03d3 into main Sep 5, 2026
9 checks passed
@marcoscaceres
marcoscaceres deleted the refactor/core-insert-style branch September 5, 2026 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Contains AI-generated logic; see AI_POLICY.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants