Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxt3): prevent removing and re-adding tags before mount #3212

Merged
merged 7 commits into from
Feb 15, 2022
Merged

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Feb 13, 2022

πŸ”— Linked issue

#2419

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR follows up on nuxt/nuxt#12980. The issue it solves occurs in the initial render cycle, if there are multiple useMeta tags for the same tag type, e.g.:

useMeta({ script: /* ... */ })
useMeta({ script: /* ... */ })

In this case, immediately triggering updateDOM after the first call causes a mismatch because we haven't yet registered the second script tag yet, and so it's removed. It's then added back, triggering the rerun.

By deferring updateDOM to mounted on the initial render, we give Vue a chance to process all these tags.

As a side effect, we are also more performant because we only trigger a single update, rather than a different one for every different useMeta call and meta tag we insert.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added bug Something isn't working nuxt3 πŸ”¨ p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage labels Feb 13, 2022
@danielroe danielroe requested a review from pi0 February 13, 2022 00:41
@danielroe danielroe self-assigned this Feb 13, 2022
@netlify
Copy link

netlify bot commented Feb 13, 2022

βœ”οΈ Deploy Preview for nuxt3-docs canceled.

πŸ”¨ Explore the source changes: 9ffb87a

πŸ” Inspect the deploy log: https://app.netlify.com/sites/nuxt3-docs/deploys/620a33fafea8cd0007b57af9

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x bug Something isn't working nuxt3 πŸ”¨ p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants