Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromvuejs/vue

Commitb6c384d

Browse files
jkzingyyx990803
authored andcommitted
fix(core): static trees should be cached on options (vuejs#6826) (vuejs#6837)
* test(once): failing test forvuejs#6826* fix(core): static trees should be cached on options (vuejs#6826)
1 parent9caed00 commitb6c384d

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

‎src/core/instance/render-helpers/render-static.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export function renderStatic (
1111
):VNode|Array<VNode>{
1212
// static trees can be rendered once and cached on the contructor options
1313
// so every instance shares the same cached trees
14-
constrenderFns=this.$options.staticRenderFns
15-
constcached=renderFns.cached||(renderFns.cached=[])
14+
constoptions=this.$options
15+
constcached=options.cached||(options.cached=[])
1616
lettree=cached[index]
1717
// if has already-rendered static tree and not inside v-for,
1818
// we can reuse the same tree by doing a shallow clone.
@@ -22,7 +22,7 @@ export function renderStatic (
2222
:cloneVNode(tree)
2323
}
2424
// otherwise, render a fresh tree.
25-
tree=cached[index]=renderFns[index].call(this._renderProxy,null,this)
25+
tree=cached[index]=options.staticRenderFns[index].call(this._renderProxy,null,this)
2626
markStatic(tree,`__static__${index}`,false)
2727
returntree
2828
}

‎test/unit/features/directives/once.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,28 @@ describe('Directive v-once', () => {
335335
vm.ok=false// teardown component with v-once
336336
}).then(done)// should not throw
337337
})
338+
339+
// #6826
340+
it('should render different component instances properly',done=>{
341+
constvm=newVue({
342+
components:{
343+
foo:{
344+
props:['name'],
345+
template:'<div v-once>{{ name }}</div>'
346+
}
347+
},
348+
template:`
349+
<div>
350+
<foo name="a" v-once></foo>
351+
<foo name="b" v-once></foo>
352+
</div>
353+
`
354+
}).$mount()
355+
waitForUpdate(()=>{
356+
expect(vm.$el.children[0].innerHTML).toBe('a')
357+
expect(vm.$el.children[1].innerHTML).toBe('b')
358+
}).then(done)
359+
})
338360
})
339361

340362
functionexpectTextContent(vm,text){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp