-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: head duplication when binding is present #9124
Conversation
🦋 Changeset detectedLatest commit: adea603 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
||
do { | ||
$$settled = true; | ||
// $$result.head is mutated by the literal expression | ||
// need to reset it if we're looping back to prevent duplication | ||
$$result.head = #previous_head; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still don't fully understand the fix - how is the binding mutating the head?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Binding doesn't mutate it, but the emitted code is like
`${($$result.head += 'head contents', '')} body contents`
so if the loop isn't settled in one go, the next iteration will add the head contents again and so on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see - I guess it makes sense then to only use the first head. Can there ever be a situation where this would prevent other head elements from showing up? Like, if there's some component inside an if block that contains a head element, will that be part of the first loop already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fine, the child component inside the if will get reexecuted after resetting the head
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what constitutes to a rerun then? Only bindings? TBH I never looked into that part of the code base much. I just want to rule out that we don't lose head content that would otherwise be rightfully added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const main = renderer.has_bindings |
Looks like it's only bindings
fixes #7879
fixes #4982
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint