mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-24 19:30:35 +03:00
fix: dont change title when value is undefined (fix #396)
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<link rel="stylesheet" href="/global.css">
|
<html>
|
||||||
<a href="/">← Examples index</a>
|
<head>
|
||||||
<div id="app"></div>
|
<title>Basic Title</title>
|
||||||
<script src="/__build__/basic.js"></script>
|
<link rel="stylesheet" href="/global.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a href="/">← Examples index</a>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script src="/__build__/basic.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
*
|
*
|
||||||
* @param {String} title - the new title of the document
|
* @param {String} title - the new title of the document
|
||||||
*/
|
*/
|
||||||
export default function updateTitle(title = document.title) {
|
export default function updateTitle(title) {
|
||||||
|
if (title === undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
document.title = title
|
document.title = title
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// set some sane defaults
|
// set some sane defaults
|
||||||
export const defaultInfo = {
|
export const defaultInfo = {
|
||||||
title: '',
|
title: undefined,
|
||||||
titleChunk: '',
|
titleChunk: '',
|
||||||
titleTemplate: '%s',
|
titleTemplate: '%s',
|
||||||
htmlAttrs: {},
|
htmlAttrs: {},
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ describe('client', () => {
|
|||||||
|
|
||||||
jest.runAllTimers()
|
jest.runAllTimers()
|
||||||
metaInfo = getMetaInfo(wrapper.vm.$parent)
|
metaInfo = getMetaInfo(wrapper.vm.$parent)
|
||||||
expect(metaInfo.title).toEqual('')
|
expect(metaInfo.title).toEqual(undefined)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('meta-info can be rendered with inject', () => {
|
test('meta-info can be rendered with inject', () => {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ describe('getMetaInfo', () => {
|
|||||||
const component = new Vue()
|
const component = new Vue()
|
||||||
|
|
||||||
expect(getMetaInfo(component)).toEqual({
|
expect(getMetaInfo(component)).toEqual({
|
||||||
title: '',
|
title: undefined,
|
||||||
titleChunk: '',
|
titleChunk: '',
|
||||||
titleTemplate: '%s',
|
titleTemplate: '%s',
|
||||||
htmlAttrs: {},
|
htmlAttrs: {},
|
||||||
@@ -654,7 +654,7 @@ describe('getMetaInfo', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(getMetaInfo(component)).toEqual({
|
expect(getMetaInfo(component)).toEqual({
|
||||||
title: '',
|
title: undefined,
|
||||||
titleChunk: '',
|
titleChunk: '',
|
||||||
titleTemplate: '%s',
|
titleTemplate: '%s',
|
||||||
htmlAttrs: {},
|
htmlAttrs: {},
|
||||||
@@ -802,7 +802,7 @@ describe('getMetaInfo', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(getMetaInfo(component)).toEqual({
|
expect(getMetaInfo(component)).toEqual({
|
||||||
title: '',
|
title: undefined,
|
||||||
titleChunk: '',
|
titleChunk: '',
|
||||||
titleTemplate: '%s',
|
titleTemplate: '%s',
|
||||||
htmlAttrs: {},
|
htmlAttrs: {},
|
||||||
|
|||||||
Reference in New Issue
Block a user