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

Commitbaabd6d

Browse files
chriscasolayyx990803
authored andcommitted
fix(compiler): warn when inline-template component has no children (fixvuejs#6703) (vuejs#6715)
1 parentc5d0fa0 commitbaabd6d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

‎src/compiler/codegen/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ function genDirectives (el: ASTElement, state: CodegenState): string | void {
309309
functiongenInlineTemplate(el:ASTElement,state:CodegenState): ?string{
310310
constast=el.children[0]
311311
if(process.env.NODE_ENV!=='production'&&(
312-
el.children.length>1||ast.type!==1
312+
el.children.length!==1||ast.type!==1
313313
)){
314314
state.warn('Inline-template components must have exactly one child element.')
315315
}

‎test/unit/modules/compiler/codegen.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,14 @@ describe('codegen', () => {
455455
'<my-component inline-template><hr><hr></my-component>',
456456
`with(this){return _c('my-component',{inlineTemplate:{render:function(){with(this){return _c('hr')}},staticRenderFns:[]}})}`
457457
)
458+
try{
459+
assertCodegen(
460+
'<my-component inline-template></my-component>',
461+
''
462+
)
463+
}catch(e){}
458464
expect('Inline-template components must have exactly one child element.').toHaveBeenWarned()
465+
expect(console.error.calls.count()).toBe(2)
459466
})
460467

461468
it('generate static trees inside v-for',()=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp