diff --git a/packages/vue-renderer/src/renderers/spa.js b/packages/vue-renderer/src/renderers/spa.js index 196e837491..8bb1a9969f 100644 --- a/packages/vue-renderer/src/renderers/spa.js +++ b/packages/vue-renderer/src/renderers/spa.js @@ -71,10 +71,18 @@ export default class SPARenderer extends BaseRenderer { // BODY_ATTRS meta.BODY_ATTRS = m.bodyAttrs.text() + // charset must come before the title to avoid encoding issues + let metaTags = m.meta.text() + const charset = m.meta.text({ charset: true }) + if (charset) { + meta.HEAD += charset + metaTags = metaTags.replace(charset, '') + } + // HEAD tags - meta.HEAD = + meta.HEAD += m.title.text() + - m.meta.text() + + metaTags + m.link.text() + m.style.text() + m.script.text() + diff --git a/packages/vue-renderer/src/renderers/ssr.js b/packages/vue-renderer/src/renderers/ssr.js index ed7aba75bf..e58b169ebc 100644 --- a/packages/vue-renderer/src/renderers/ssr.js +++ b/packages/vue-renderer/src/renderers/ssr.js @@ -130,7 +130,14 @@ export default class SSRRenderer extends BaseRenderer { }) if (meta) { - HEAD += meta.title.text() + meta.meta.text() + // charset must come before the title to avoid encoding issues + let metaTags = meta.meta.text() + const charset = meta.meta.text({ charset: true }) + if (charset) { + HEAD += charset + metaTags = metaTags.replace(charset, '') + } + HEAD += meta.title.text() + metaTags } // Add meta if router base specified diff --git a/test/dev/basic.ssr.test.js b/test/dev/basic.ssr.test.js index 8cc0a7f7f1..646bafd1bb 100644 --- a/test/dev/basic.ssr.test.js +++ b/test/dev/basic.ssr.test.js @@ -86,6 +86,12 @@ describe('basic ssr', () => { expect(html).toContain('

I can haz meta tags

') expect(html).toContain('