fix(head): case http-equiv correctly (#7190)

This commit is contained in:
Harlan Wilton 2022-09-03 22:31:09 +10:00 committed by GitHub
parent d31e1f03a1
commit fe3fc34b12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View File

@ -197,9 +197,17 @@ export const Meta = defineComponent({
httpEquiv: String as PropType<HTTPEquiv>,
name: String
},
setup: setupForUseMeta(meta => ({
meta: [meta]
}))
setup: setupForUseMeta((props) => {
const meta = { ...props }
// fix casing for http-equiv
if (meta.httpEquiv) {
meta['http-equiv'] = meta.httpEquiv
delete meta.httpEquiv
}
return {
meta: [meta]
}
})
})
// <style>

View File

@ -165,6 +165,12 @@ describe('head tags', () => {
expect(indexHtml).toContain('<title>Basic fixture</title>')
})
it('should render http-equiv correctly', async () => {
const html = await $fetch('/head')
// http-equiv should be rendered kebab case
expect(html).toContain('<meta content="default-src https" http-equiv="content-security-policy">')
})
// TODO: Doesn't adds header in test environment
// it.todo('should render stylesheet link tag (SPA mode)', async () => {
// const html = await $fetch('/head', { headers: { 'x-nuxt-no-ssr': '1' } })

View File

@ -35,6 +35,7 @@ export default {
<div>
<Head>
<Title>Using a dynamic component</Title>
<Meta http-equiv="content-security-policy" content="default-src https" />
</Head>
</div>
</template>