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

Commite3d7a03

Browse files
committed
fix special static attrs as dom prop
1 parentc9fa2e6 commite3d7a03

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

‎flow/compiler.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ declare type ASTElement = {
7575
staticInFor?:boolean;
7676
staticProcessed?:boolean;
7777
hasBindings?:boolean;
78+
hasNormalProp?:true;
7879

7980
text?:string;
8081
attrs?:Array<{name:string;value:string}>;

‎src/compiler/optimizer.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*@flow */
22

3-
import{makeMap,isBuiltInTag,cached,no}from'shared/util'
3+
import{makeMap,isBuiltInTag,cached,no,remove}from'shared/util'
44

55
letisStaticKey
66
letisPlatformReservedTag
@@ -99,13 +99,17 @@ function isStatic (node: ASTNode): boolean {
9999
if(node.type===3){// text
100100
returntrue
101101
}
102+
constnodeAttrs=Object.keys(node)
103+
if(!node.hasNormalProp&&node.props&&node.props.length){
104+
remove(nodeAttrs,'props')
105+
}
102106
return!!(node.pre||(
103107
!node.hasBindings&&// no dynamic bindings
104108
!node.if&&!node.for&&// not v-if or v-for or v-else
105109
!isBuiltInTag(node.tag)&&// not a built-in
106110
isPlatformReservedTag(node.tag)&&// not a component
107111
!isDirectChildOfTemplateFor(node)&&
108-
Object.keys(node).every(isStaticKey)
112+
nodeAttrs.every(isStaticKey)
109113
))
110114
}
111115

‎src/compiler/parser/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ function processAttrs (el) {
444444
}
445445
}
446446
if(isProp||platformMustUseProp(el.tag,name)){
447+
el.hasNormalProp=true
447448
addProp(el,name,value)
448449
}else{
449450
addAttr(el,name,value)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ describe('optimizer', () => {
191191
expect(ast.children[0].static).toBe(false)
192192
})
193193

194+
it('mark static with static dom property',()=>{
195+
constast=parse('<input type="text" value="1">',baseOptions)
196+
optimize(ast,baseOptions)
197+
expect(ast.static).toBe(true)
198+
})
199+
194200
it('not root ast',()=>{
195201
constast=null
196202
optimize(ast,baseOptions)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp