Skip to content

Commit

Permalink
fix: place the charset meta tag at the top of the head
Browse files Browse the repository at this point in the history
  • Loading branch information
await-ovo committed Apr 29, 2022
1 parent ea779c5 commit 130d5d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/shared/lib/head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function reduceComponents(
)
.reduce(onlyReactElement, [])
.reverse()
.concat(defaultHead(props.inAmpMode))
.concat(defaultHead(props.inAmpMode).reverse())
.filter(unique())
.reverse()
.map((c: React.ReactElement<any>, i: number) => {
Expand Down
13 changes: 13 additions & 0 deletions test/e2e/next-head/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ describe('should set-up next', () => {
})
afterAll(() => next.destroy())

it(`should place charset element at the top of <head>`, async () => {
const browser = await webdriver(next.url, '/')

const html = await browser.eval(() => {
const head = document.querySelector('head')
return head.innerHTML
})

expect(html).toContain(
`<meta charset="utf-8"><meta name="viewport" content="width=device-width"><meta name="test-head-1" content="hello">`
)
})

it('should have correct head tags in initial document', async () => {
const html = await renderViaHTTP(next.url, '/')
const $ = cheerio.load(html)
Expand Down

0 comments on commit 130d5d9

Please sign in to comment.