Skip to content

Commit 35ee5b1

Browse files
committed
remove staticAttrs
1 parent 3e06c57 commit 35ee5b1

File tree

13 files changed

+46
-62
lines changed

13 files changed

+46
-62
lines changed

flow/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ declare type ASTElement = {
7171
static?: boolean;
7272
staticRoot?: boolean;
7373
staticProcessed?: boolean;
74+
hasBindings?: boolean;
7475

7576
text?: string;
7677
attrs?: Array<{ name: string; value: string }>;
7778
props?: Array<{ name: string; value: string }>;
78-
staticAttrs?: Array<{ name: string; value: string }>;
7979
plain?: boolean;
8080
pre?: true;
8181
ns?: string;

flow/vnode.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ declare interface VNodeData {
4242
props?: { [key: string]: any };
4343
attrs?: { [key: string]: string };
4444
domProps?: { [key: string]: any };
45-
staticAttrs?: { [key: string]: string };
4645
hook?: { [key: string]: Function };
4746
on?: ?{ [key: string]: Function | Array<Function> };
4847
nativeOn?: { [key: string]: Function | Array<Function> };

src/compiler/codegen/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function generate (
3131
platformDirectives = options.directives || {}
3232
isPlatformReservedTag = options.isReservedTag || no
3333
const code = ast ? genElement(ast) : '_h("div")'
34+
// console.log(code)
3435
staticRenderFns = prevStaticRenderFns
3536
return {
3637
render: `with(this){return ${code}}`,
@@ -150,10 +151,6 @@ function genData (el: ASTElement): string | void {
150151
if (el.attrs) {
151152
data += `attrs:{${genProps(el.attrs)}},`
152153
}
153-
// static attributes
154-
if (el.staticAttrs) {
155-
data += `staticAttrs:{${genProps(el.staticAttrs)}},`
156-
}
157154
// DOM props
158155
if (el.props) {
159156
data += `domProps:{${genProps(el.props)}},`

src/compiler/helpers.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ export function addAttr (el: ASTElement, name: string, value: string) {
2121
(el.attrs || (el.attrs = [])).push({ name, value })
2222
}
2323

24-
export function addStaticAttr (el: ASTElement, name: string, value: string) {
25-
(el.staticAttrs || (el.staticAttrs = [])).push({ name, value })
26-
}
27-
2824
export function addDirective (
2925
el: ASTElement,
3026
name: string,

src/compiler/optimizer.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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,staticAttrs' +
33+
'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
3434
(keys ? ',' + keys : '')
3535
)
3636
}
@@ -68,9 +68,10 @@ function isStatic (node: ASTNode): boolean {
6868
return true
6969
}
7070
return !!(node.pre || (
71+
!node.hasBindings && // no dynamic bindings
7172
!node.if && !node.for && // not v-if or v-for or v-else
7273
!isBuiltInTag(node.tag) && // not a built-in
7374
isPlatformReservedTag(node.tag) && // not a component
74-
(node.plain || Object.keys(node).every(isStaticKey)) // no dynamic bindings
75+
Object.keys(node).every(isStaticKey)
7576
))
7677
}

src/compiler/parser/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
getAndRemoveAttr,
1010
addProp,
1111
addAttr,
12-
addStaticAttr,
1312
addHandler,
1413
addDirective,
1514
getBindingAttr,
@@ -242,7 +241,7 @@ function processPre (el) {
242241
function processRawAttrs (el) {
243242
const l = el.attrsList.length
244243
if (l) {
245-
const attrs = el.staticAttrs = new Array(l)
244+
const attrs = el.attrs = new Array(l)
246245
for (let i = 0; i < l; i++) {
247246
attrs[i] = {
248247
name: el.attrsList[i].name,
@@ -361,6 +360,8 @@ function processAttrs (el) {
361360
name = list[i].name
362361
value = list[i].value
363362
if (dirRE.test(name)) {
363+
// mark element as dynamic
364+
el.hasBindings = true
364365
// modifiers
365366
modifiers = parseModifiers(name)
366367
if (modifiers) {
@@ -402,7 +403,7 @@ function processAttrs (el) {
402403
)
403404
}
404405
}
405-
addStaticAttr(el, name, JSON.stringify(value))
406+
addAttr(el, name, JSON.stringify(value))
406407
}
407408
}
408409
}

src/core/vdom/create-component.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,13 @@ function extractProps (data: VNodeData, Ctor: Class<Component>): ?Object {
234234
return
235235
}
236236
const res = {}
237-
const { attrs, props, domProps, staticAttrs } = data
238-
if (attrs || props || domProps || staticAttrs) {
237+
const { attrs, props, domProps } = data
238+
if (attrs || props || domProps) {
239239
for (const key in propOptions) {
240240
const altKey = hyphenate(key)
241241
checkProp(res, props, key, altKey, true) ||
242242
checkProp(res, attrs, key, altKey) ||
243-
checkProp(res, domProps, key, altKey) ||
244-
checkProp(res, staticAttrs, key, altKey)
243+
checkProp(res, domProps, key, altKey)
245244
}
246245
}
247246
return res

src/platforms/web/runtime/modules/attrs.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,6 @@ function setAttr (el: Element, key: string, value: any) {
6464
}
6565

6666
export default {
67-
create: function (_: any, vnode: VNodeWithData) {
68-
const attrs = vnode.data.staticAttrs
69-
if (attrs) {
70-
for (const key in attrs) {
71-
setAttr(vnode.elm, key, attrs[key])
72-
}
73-
}
74-
updateAttrs(_, vnode)
75-
},
67+
create: updateAttrs,
7668
update: updateAttrs
7769
}

src/platforms/web/server/modules/attrs.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import {
88

99
export default function renderAttrs (node: VNodeWithData): string {
1010
let res = ''
11-
if (node.data.staticAttrs) {
12-
res += render(node.data.staticAttrs)
13-
}
1411
if (node.data.attrs) {
1512
res += render(node.data.attrs)
1613
}

src/platforms/web/server/modules/style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { hyphenate, toObject } from 'shared/util'
44

55
export default function renderStyle (node: VNodeWithData): ?string {
6-
const staticStyle = node.data.staticAttrs && node.data.staticAttrs.style
6+
const staticStyle = node.data.attrs && node.data.attrs.style
77
if (node.data.style || staticStyle) {
88
let styles = node.data.style
99
let res = ' style="'

0 commit comments

Comments
 (0)