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

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

Merged
merged 1 commit into from
Sep 3, 2022
Merged
Show file tree
Hide file tree
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
14 changes: 11 additions & 3 deletions packages/nuxt/src/head/runtime/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 6 additions & 0 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' } })
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/basic/pages/head.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>