Skip to content

Commit

Permalink
Revert "fix: set ssr appId in mounted hook"
Browse files Browse the repository at this point in the history
This reverts commit 2dd1697.
  • Loading branch information
pimlie committed Jun 9, 2019
1 parent 2dd1697 commit b2a7a84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/shared/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ export default function createMixin(Vue, options) {
this.$root._vueMeta.initialized = this.$isServer

if (!this.$root._vueMeta.initialized) {
// we use the mounted hook here as on page load
ensuredPush(this.$options, 'mounted', () => {
ensuredPush(this.$options, 'beforeMount', () => {
// if this Vue-app was server rendered, set the appId to 'ssr'
// only one SSR app per page is supported
if (this.$root.$el && this.$root.$el.hasAttribute('data-server-rendered')) {
this.$root._vueMeta.appId = 'ssr'
}
})

// we use the mounted hook here as on page load
ensuredPush(this.$options, 'mounted', () => {
if (!this.$root._vueMeta.initialized) {
// used in triggerUpdate to check if a change was triggered
// during initialization
Expand Down
18 changes: 5 additions & 13 deletions test/unit/components.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,12 @@ describe('client', () => {

test('doesnt update when ssr attribute is set', () => {
html.setAttribute(defaultOptions.ssrAttribute, 'true')
const wrapper = mount(HelloWorld, {
localVue: Vue,
attrs: {
'data-server-rendered': true
}
})
const wrapper = mount(HelloWorld, { localVue: Vue })

const { tags } = wrapper.vm.$meta().refresh()
expect(tags).toBe(false)
// TODO: fix this test, not sure how to create a wrapper with a attri
// bute data-server-rendered="true"
expect(tags).not.toBe(false)
})

test('changed function is called', async () => {
Expand Down Expand Up @@ -232,12 +229,7 @@ describe('client', () => {
}
})

const wrapper = mount(component, {
localVue: Vue,
attrs: {
'data-server-rendered': true
}
})
const wrapper = mount(component, { localVue: Vue })
expect(html.getAttribute('theme')).not.toBe('dark')

await vmTick(wrapper.vm)
Expand Down

0 comments on commit b2a7a84

Please sign in to comment.