Skip to content

Commit

Permalink
Revert "Mark node with static props as static (#4662)"
Browse files Browse the repository at this point in the history
This reverts commit 9265724.
  • Loading branch information
yyx990803 committed Jan 13, 2017
1 parent bb42625 commit 4e830ba
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 20 deletions.
1 change: 0 additions & 1 deletion flow/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ declare type ASTElement = {
plain?: boolean;
pre?: true;
ns?: string;
staticProps?: Array<string>;

component?: string;
inlineTemplate?: true;
Expand Down
5 changes: 1 addition & 4 deletions src/compiler/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ export function pluckModuleFunction<F: Function> (
: []
}

export function addProp (el: ASTElement, name: string, value: string, fromStaticAttr?: boolean) {
if (fromStaticAttr) {
(el.staticProps || (el.staticProps = [])).push(name)
}
export function addProp (el: ASTElement, name: string, value: string) {
(el.props || (el.props = [])).push({ name, value })
}

Expand Down
10 changes: 3 additions & 7 deletions src/compiler/optimizer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @flow */

import { makeMap, isBuiltInTag, cached, no, remove } from 'shared/util'
import { makeMap, isBuiltInTag, cached, no } from 'shared/util'

let isStaticKey
let isPlatformReservedTag
Expand Down Expand Up @@ -30,7 +30,7 @@ export function optimize (root: ?ASTElement, options: CompilerOptions) {

function genStaticKeys (keys: string): Function {
return makeMap(
'type,tag,attrsList,attrsMap,plain,parent,children,attrs,staticProps' +
'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
(keys ? ',' + keys : '')
)
}
Expand Down Expand Up @@ -99,17 +99,13 @@ function isStatic (node: ASTNode): boolean {
if (node.type === 3) { // text
return true
}
const nodeAttrs = Object.keys(node)
if (node.staticProps && node.props && node.staticProps.length === node.props.length) {
remove(nodeAttrs, 'props')
}
return !!(node.pre || (
!node.hasBindings && // no dynamic bindings
!node.if && !node.for && // not v-if or v-for or v-else
!isBuiltInTag(node.tag) && // not a built-in
isPlatformReservedTag(node.tag) && // not a component
!isDirectChildOfTemplateFor(node) &&
nodeAttrs.every(isStaticKey)
Object.keys(node).every(isStaticKey)
))
}

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,9 @@ function processAttrs (el) {
// so that patches between dynamic/static are consistent
if (platformMustUseProp(el.tag, name)) {
if (name === 'value') {
addProp(el, name, JSON.stringify(value), true)
addProp(el, name, JSON.stringify(value))
} else {
addProp(el, name, 'true', true)
addProp(el, name, 'true')
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions test/unit/modules/compiler/optimizer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,6 @@ describe('optimizer', () => {
expect(ast.children[0].static).toBe(false)
})

it('mark static with static dom property', () => {
const ast = parse('<input type="text" value="1">', baseOptions)
optimize(ast, baseOptions)
expect(ast.static).toBe(true)
})

it('not root ast', () => {
const ast = null
optimize(ast, baseOptions)
Expand Down

0 comments on commit 4e830ba

Please sign in to comment.