diff --git a/examples/nuxt3/pages/index.vue b/examples/nuxt3/pages/index.vue index 04e511c..1c0a590 100644 --- a/examples/nuxt3/pages/index.vue +++ b/examples/nuxt3/pages/index.vue @@ -34,5 +34,8 @@ useHead({ second page + + red + diff --git a/examples/nuxt3/pages/red.vue b/examples/nuxt3/pages/red.vue new file mode 100644 index 0000000..2b98c53 --- /dev/null +++ b/examples/nuxt3/pages/red.vue @@ -0,0 +1,17 @@ + + + diff --git a/src/dom/update-dom.ts b/src/dom/update-dom.ts index 415f6ca..2045ff0 100644 --- a/src/dom/update-dom.ts +++ b/src/dom/update-dom.ts @@ -27,16 +27,21 @@ export const updateDOM = async (head: HeadClient, previousTags: Set, doc if (typeof tag._runtime.textContent !== 'undefined') document.title = tag._runtime.textContent break - case 'htmlAttrs': - case 'bodyAttrs': - setAttrs(document[tag.tag === 'htmlAttrs' ? 'documentElement' : 'body'], tag.props) - break - default: + + case 'base': + case 'meta': + case 'link': + case 'style': + case 'script': + case 'noscript': tags[tag.tag] = tags[tag.tag] || [] tags[tag.tag].push(tag) + break } } + setAttrs(document.documentElement, headTags.find(t => t.tag === 'htmlAttrs')?.props || {}) + setAttrs(document.body, headTags.find(t => t.tag === 'bodyAttrs')?.props || {}) const tagKeys = new Set([...Object.keys(tags), ...previousTags]) for (const tag of tagKeys) updateElements(document, tag, tags[tag] || [])