diff --git a/examples/basic/index.html b/examples/basic/index.html index a12f752..07c7aa2 100644 --- a/examples/basic/index.html +++ b/examples/basic/index.html @@ -1,5 +1,12 @@ - -← Examples index -
- + + + Basic Title + + + + ← Examples index +
+ + + diff --git a/src/client/updaters/title.js b/src/client/updaters/title.js index 48bd43f..3db3f1c 100644 --- a/src/client/updaters/title.js +++ b/src/client/updaters/title.js @@ -3,6 +3,10 @@ * * @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 } diff --git a/src/shared/constants.js b/src/shared/constants.js index efedfaa..1c232f3 100644 --- a/src/shared/constants.js +++ b/src/shared/constants.js @@ -4,7 +4,7 @@ // set some sane defaults export const defaultInfo = { - title: '', + title: undefined, titleChunk: '', titleTemplate: '%s', htmlAttrs: {}, diff --git a/test/unit/components.test.js b/test/unit/components.test.js index 5171ad3..1abc9d5 100644 --- a/test/unit/components.test.js +++ b/test/unit/components.test.js @@ -90,7 +90,7 @@ describe('client', () => { jest.runAllTimers() metaInfo = getMetaInfo(wrapper.vm.$parent) - expect(metaInfo.title).toEqual('') + expect(metaInfo.title).toEqual(undefined) }) test('meta-info can be rendered with inject', () => { diff --git a/test/unit/getMetaInfo.test.js b/test/unit/getMetaInfo.test.js index 0ae0e2c..a7b631d 100644 --- a/test/unit/getMetaInfo.test.js +++ b/test/unit/getMetaInfo.test.js @@ -13,7 +13,7 @@ describe('getMetaInfo', () => { const component = new Vue() expect(getMetaInfo(component)).toEqual({ - title: '', + title: undefined, titleChunk: '', titleTemplate: '%s', htmlAttrs: {}, @@ -654,7 +654,7 @@ describe('getMetaInfo', () => { }) expect(getMetaInfo(component)).toEqual({ - title: '', + title: undefined, titleChunk: '', titleTemplate: '%s', htmlAttrs: {}, @@ -802,7 +802,7 @@ describe('getMetaInfo', () => { }) expect(getMetaInfo(component)).toEqual({ - title: '', + title: undefined, titleChunk: '', titleTemplate: '%s', htmlAttrs: {},