Skip to content
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> vNode handling in Vue 3 adapter #1570

Merged
merged 3 commits into from
May 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion packages/vue3/src/head.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,26 @@ const Head: InertiaHead = defineComponent({
renderNodes(nodes) {
return this.addTitleElement(
nodes
.flatMap((node) => (node.type.toString().startsWith('Symbol') && node.children ? node.children : node))
.flatMap((node) => this.resolveNode(node))
.map((node) => this.renderTag(node))
.filter((node) => node),
)
},
resolveNode(node) {
const nodeType = node.type && node.type.toString()
if (typeof node.type === 'function') {
return this.resolveNode(node.type())
} else if (typeof node.type === 'object') {
console.warn(`Using components in the <Head> component is not supported.`)
return []
} else if (/(fragment|fgt)/i.test(nodeType) && node.children) {
return node.children.flatMap((child) => this.resolveNode(child))
} else if (/(comment|cmt)/i.test(nodeType)) {
return []
} else {
return node
}
},
},
render() {
this.provider.update(this.renderNodes(this.$slots.default ? this.$slots.default() : []))
Expand Down