Skip to content

Conversation

@serhalp
Copy link
Member

@serhalp serhalp commented Dec 5, 2025

Description

In #39306 we introduced a workaround that wraps the Gatsby Head API elements in an <svg> wrapper. React under the hood creates these children elements in the "SVG" namespace.

In the case of <title>, this is problematic because when we insert it into the real <head>, browsers (as far as we can tell) do not trigger an update of document.title because this only occurs for <title> nodes in the HTML namespace. A node's namespace is immutable, even when using cloneNode() or importNode().

The only way to "reset" the namespace is to recreate a node.

Documentation

N/A

Tests

Augmented existing <title> tests to also verify the actual page title

Related Issues

See reports here: #39180 (comment)

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Dec 5, 2025
@serhalp serhalp force-pushed the fix/react-head-document-title branch 2 times, most recently from 56b1fb3 to ded6a14 Compare December 5, 2025 20:20
These are nondeterministic and conflict with test output assertions
In #39306 we introduced a workaround that wraps the Gatsby
Head API elements in an `<svg>` wrapper. React under the hood creates these children elements in the
"SVG" namespace. In the case of `<title>`, this is problematic because when we insert it into the
real `<head>`, browsers (as far as we can tell) do not trigger an update of `document.title` because
this only occurs for `<title>` nodes in the HTML namespace. A node's namespace is immutable, even
when using `cloneNode()` or `importNode()`. The only way to "reset" the namespace is to recreate a
node.
@serhalp serhalp force-pushed the fix/react-head-document-title branch from ded6a14 to b2e83e8 Compare December 5, 2025 20:51
@serhalp serhalp marked this pull request as ready for review December 5, 2025 21:51
GATSBY_CPU_COUNT: 2
COMPILER_OPTIONS: GATSBY_MAJOR=<< parameters.gatsby_major >>
NODE_NO_WARNINGS: 1
BROWSERSLIST_IGNORE_OLD_DATA: true
Copy link
Member Author

Choose a reason for hiding this comment

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

This is nondeterministic and was messing with some stdout test assertions

no_output_timeout: 15m
environment:
NODE_OPTIONS: --max-old-space-size=2048
NODE_NO_WARNINGS: 1
Copy link
Member Author

Choose a reason for hiding this comment

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

This was missing from this Windows job (present in the others)

@serhalp serhalp requested a review from pieh December 5, 2025 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants