fix: let the app's htmlAttributes/bodyAttributes take precedence over the ones set by Vike extensions - #228
Merged
Conversation
This was referenced Sep 18, 2026
nitedani
force-pushed
the
claude/tag-attributes-precedence-ljv9nc
branch
from
September 18, 2026 14:59
38b2e07 to
42eac6c
Compare
…over the ones set by Vike extensions For cumulative settings, `getHeadSetting()` returned the values in the order Vike provides them (most specific value first, values set by Vike extensions last) followed by the values set by `useConfig()`, and the tag attributes were merged in that order with the last value winning upon conflict. Consequently, upon conflict, a value set by a Vike extension would override the app's value, and a value set by `+config.js` would override the value set by `+htmlAttributes.js`. `getHeadSetting()` now returns the values of cumulative settings sorted by increasing precedence (values set by Vike extensions first, the app's most specific value last, then the values set by `useConfig()`), so that merging them in order yields the value with the highest precedence. Values set by `useConfig()` keep the highest precedence. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MdJwhUKSfXPVuSvXyxBpr7
nitedani
force-pushed
the
claude/tag-attributes-precedence-ljv9nc
branch
from
September 19, 2026 07:10
42eac6c to
5efce2f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The values of the cumulative settings
+htmlAttributesand+bodyAttributeswere merged in the order Vike provides them (most specific value first, values set by Vike extensions last), with the last value winning upon conflict. So, upon conflict:+config.jsoverrode the value set by+htmlAttributes.js/+bodyAttributes.js.That's the opposite of how every other Vike setting resolves. (The order of cumulative values is pinned by Vike's playground test
test/playground/pages/config-meta/cumulative/.)Fix
The root cause is in
getHeadSetting()(packages/vike-react/src/integration/getHeadSetting.tsx): for cumulative settings, it concatenated the config values (sorted by decreasing precedence) with theuseConfig()values (highest precedence, appended last), so no merge order could get both right.getHeadSetting()now returns the values of a cumulative setting sorted by increasing precedence: the values set by Vike extensions first, then the app's values (the most specific one last), then the values set byuseConfig(). Merging them in order, asmergeTagAttributesList()inonRenderHtml.tsxdoes, thus yields the most specific value. Values set byuseConfig()keep the highest precedence (unchanged).Only
htmlAttributesandbodyAttributesgo through that code path (Headis rendered directly frompageContext.config.Head, in Vike's order).Related
+rootAttributessetting (React: Allow attributes to be added to the root node vike#3513) stacks on this PR: feat: new setting +rootAttributes #229.🤖 Generated with Claude Code
https://claude.ai/code/session_01MdJwhUKSfXPVuSvXyxBpr7