Skip to content

Fix misleading error messages in replaceSync/replace and fix typo in MediaList-impl.js#4108

Merged
domenic merged 2 commits intomerge-cssstylefrom
copilot/sub-pr-4092
Mar 13, 2026
Merged

Fix misleading error messages in replaceSync/replace and fix typo in MediaList-impl.js#4108
domenic merged 2 commits intomerge-cssstylefrom
copilot/sub-pr-4092

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 13, 2026

replaceSync() and replace() combined two distinct failure conditions into a single check with a single error message, causing the "non-constructed" message to appear even when the sheet was constructed but mid-replacement.

Changes

  • CSSStyleSheet-impl.js: Split the !this._constructed || this._disallowModification guard into two separate checks in both replaceSync() and replace(), each with an accurate message:
    • Non-constructed → "Cannot call replaceSync/replace on non-constructed CSSStyleSheet."
    • Modification in progress → "The stylesheet is currently being modified." (consistent with #checkModificationAllowed())
// Before
if (!this._constructed || this._disallowModification) {
  throw DOMException.create(this._globalObject, [
    "Cannot call replaceSync on non-constructed CSSStyleSheet.",
    "NotAllowedError"
  ]);
}

// After
if (!this._constructed) {
  throw DOMException.create(this._globalObject, [
    "Cannot call replaceSync on non-constructed CSSStyleSheet.",
    "NotAllowedError"
  ]);
}
if (this._disallowModification) {
  throw DOMException.create(this._globalObject, [
    "The stylesheet is currently being modified.",
    "NotAllowedError"
  ]);
}
  • MediaList-impl.js: Fix typo "spec-complaint""spec-compliant" in comment.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…mpl.js

Co-authored-by: domenic <617481+domenic@users.noreply.github.com>
Copilot AI changed the title [WIP] [WIP] Address feedback from PR #4092 review comments Fix misleading error messages in replaceSync/replace and fix typo in MediaList-impl.js Mar 13, 2026
Copilot AI requested a review from domenic March 13, 2026 10:37
@domenic domenic marked this pull request as ready for review March 13, 2026 10:42
@domenic domenic merged commit 4f29df1 into merge-cssstyle Mar 13, 2026
@domenic domenic deleted the copilot/sub-pr-4092 branch March 13, 2026 10:42
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