Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/core/instance/render-helpers/render-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export function renderStatic (
): VNode | Array<VNode> {
// static trees can be rendered once and cached on the contructor options
// so every instance shares the same cached trees
const renderFns = this.$options.staticRenderFns
const cached = renderFns.cached || (renderFns.cached = [])
const options = this.$options
const cached = options.cached || (options.cached = [])
let tree = cached[index]
// if has already-rendered static tree and not inside v-for,
// we can reuse the same tree by doing a shallow clone.
Expand All @@ -22,7 +22,7 @@ export function renderStatic (
: cloneVNode(tree)
}
// otherwise, render a fresh tree.
tree = cached[index] = renderFns[index].call(this._renderProxy, null, this)
tree = cached[index] = options.staticRenderFns[index].call(this._renderProxy, null, this)
markStatic(tree, `__static__${index}`, false)
return tree
}
Expand Down
22 changes: 22 additions & 0 deletions test/unit/features/directives/once.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,28 @@ describe('Directive v-once', () => {
vm.ok = false // teardown component with v-once
}).then(done) // should not throw
})

// #6826
it('should render different component instances properly', done => {
const vm = new Vue({
components: {
foo: {
props: ['name'],
template: '<div v-once>{{ name }}</div>'
}
},
template: `
<div>
<foo name="a" v-once></foo>
<foo name="b" v-once></foo>
</div>
`
}).$mount()
waitForUpdate(() => {
expect(vm.$el.children[0].innerHTML).toBe('a')
expect(vm.$el.children[1].innerHTML).toBe('b')
}).then(done)
})
})

function expectTextContent (vm, text) {
Expand Down