Skip to content

Guard caniuse table rendering against missing .head dl element - #5374

Open
brian-soltani wants to merge 3 commits into
speced:mainfrom
brian-soltani:patch-1
Open

Guard caniuse table rendering against missing .head dl element#5374
brian-soltani wants to merge 3 commits into
speced:mainfrom
brian-soltani:patch-1

Conversation

@brian-soltani

Copy link
Copy Markdown

run() assumed document.querySelector(".head dl") always finds an element and used optional chaining on headDlElem to avoid crashing when it doesn't. That silently no-ops instead of surfacing the problem, and it still throws later since headDlElem is read unguarded elsewhere in the function.

This adds an early return with a showWarning() call when the .head dl element isn't found, matching the existing pattern used in implementation-status.js, and removes the now-redundant optional chaining on the two remaining headDlElem accesses.

Closes #5370

run() assumed document.querySelector(".head dl") always finds an element and used optional chaining on headDlElem to avoid crashing when it doesn't. That silently no-ops instead of surfacing the problem, and it still throws later since headDlElem is read unguarded elsewhere in the function.

This adds an early return with a showWarning() call when the .head dl element isn't found, matching the existing pattern used in implementation-status.js, and removes the now-redundant optional chaining on the two remaining headDlElem accesses.

Closes speced#5370
@marcoscaceres
marcoscaceres requested a balanced review from Copilot August 21, 2026 02:39

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.

Pull request overview

Adds safe handling when the caniuse table’s target element is missing.

Changes:

  • Emits a warning and exits early when .head dl is unavailable.
  • Removes redundant optional chaining after the guard.

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

Comment thread src/core/caniuse.js Outdated
Comment thread src/core/caniuse.js
Comment on lines +89 to +92
if (!headDlElem) {
const msg = `Can't render caniuse browser support table: no ".head dl" element was found.`;
showWarning(msg, name);
return;
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@marcoscaceres marcoscaceres 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.

Agree with copilot. This needs a test 🙏 otherwise looks good.

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.

core/caniuse silently drops the browser-support table when .head dl is missing

3 participants