Skip to content

Commit 4e830ba

Browse files
committed
Revert "Mark node with static props as static (#4662)"
This reverts commit 9265724.
1 parent bb42625 commit 4e830ba

File tree

5 files changed

+6
-20
lines changed

5 files changed

+6
-20
lines changed

Diff for: flow/compiler.js

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ declare type ASTElement = {
8282
plain?: boolean;
8383
pre?: true;
8484
ns?: string;
85-
staticProps?: Array<string>;
8685

8786
component?: string;
8887
inlineTemplate?: true;

Diff for: src/compiler/helpers.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ export function pluckModuleFunction<F: Function> (
1515
: []
1616
}
1717

18-
export function addProp (el: ASTElement, name: string, value: string, fromStaticAttr?: boolean) {
19-
if (fromStaticAttr) {
20-
(el.staticProps || (el.staticProps = [])).push(name)
21-
}
18+
export function addProp (el: ASTElement, name: string, value: string) {
2219
(el.props || (el.props = [])).push({ name, value })
2320
}
2421

Diff for: src/compiler/optimizer.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

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

55
let isStaticKey
66
let isPlatformReservedTag
@@ -30,7 +30,7 @@ export function optimize (root: ?ASTElement, options: CompilerOptions) {
3030

3131
function genStaticKeys (keys: string): Function {
3232
return makeMap(
33-
'type,tag,attrsList,attrsMap,plain,parent,children,attrs,staticProps' +
33+
'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
3434
(keys ? ',' + keys : '')
3535
)
3636
}
@@ -99,17 +99,13 @@ function isStatic (node: ASTNode): boolean {
9999
if (node.type === 3) { // text
100100
return true
101101
}
102-
const nodeAttrs = Object.keys(node)
103-
if (node.staticProps && node.props && node.staticProps.length === node.props.length) {
104-
remove(nodeAttrs, 'props')
105-
}
106102
return !!(node.pre || (
107103
!node.hasBindings && // no dynamic bindings
108104
!node.if && !node.for && // not v-if or v-for or v-else
109105
!isBuiltInTag(node.tag) && // not a built-in
110106
isPlatformReservedTag(node.tag) && // not a component
111107
!isDirectChildOfTemplateFor(node) &&
112-
nodeAttrs.every(isStaticKey)
108+
Object.keys(node).every(isStaticKey)
113109
))
114110
}
115111

Diff for: src/compiler/parser/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,9 @@ function processAttrs (el) {
481481
// so that patches between dynamic/static are consistent
482482
if (platformMustUseProp(el.tag, name)) {
483483
if (name === 'value') {
484-
addProp(el, name, JSON.stringify(value), true)
484+
addProp(el, name, JSON.stringify(value))
485485
} else {
486-
addProp(el, name, 'true', true)
486+
addProp(el, name, 'true')
487487
}
488488
}
489489
}

Diff for: test/unit/modules/compiler/optimizer.spec.js

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

194-
it('mark static with static dom property', () => {
195-
const ast = parse('<input type="text" value="1">', baseOptions)
196-
optimize(ast, baseOptions)
197-
expect(ast.static).toBe(true)
198-
})
199-
200194
it('not root ast', () => {
201195
const ast = null
202196
optimize(ast, baseOptions)

0 commit comments

Comments
 (0)