Skip to content

Commit ad11aa1

Browse files
committed
fix syncness
1 parent e094b00 commit ad11aa1

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/compiler/codegen.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ function genFor (el, exp) {
3636
}
3737
const alias = inMatch[1].trim()
3838
exp = inMatch[2].trim()
39-
const key = el.attrsMap['track-by'] || 'undefined'
40-
return `(${exp}).map(function (${alias}, $index) {return ${genElement(el, key) }})`
39+
let key = getAttr(el, 'track-by')
40+
if (!key) {
41+
key ='undefined'
42+
} else if (key !== '$index') {
43+
key = alias + '["' + key + '"]'
44+
}
45+
return `(${exp}).map(function (${alias}, $index) {return ${genElement(el, key)}})`
4146
}
4247

4348
function genData (el, key) {
@@ -48,11 +53,13 @@ function genData (el, key) {
4853
if (key) {
4954
data += `key:${key},`
5055
}
51-
if (el.attrsMap[':class']) {
52-
data += `class: ${el.attrsMap[':class']},`
56+
const classBinding = getAttr(el, ':class') || getAttr(el, 'v-bind:class')
57+
if (classBinding) {
58+
data += `class: ${classBinding},`
5359
}
54-
if (el.attrsMap['class']) {
55-
data += `staticClass: "${el.attrsMap['class']}"`
60+
const staticClass = getAttr(el, 'class')
61+
if (staticClass) {
62+
data += `staticClass: "${staticClass}",`
5663
}
5764
let attrs = `attrs:{`
5865
let props = `props:{`
@@ -66,9 +73,7 @@ function genData (el, key) {
6673
let value = attr.value
6774
if (bindRE.test(name)) {
6875
name = name.replace(bindRE, '')
69-
if (name === 'class') {
70-
continue
71-
} else if (name === 'style') {
76+
if (name === 'style') {
7277
data += `style: ${value},`
7378
} else if (mustUsePropsRE.test(name)) {
7479
hasProps = true
@@ -88,7 +93,7 @@ function genData (el, key) {
8893
addHandler(events, 'input', `${value}=$event.target.value`)
8994
} else if (dirRE.test(name)) {
9095
// TODO: normal directives
91-
} else if (name !== 'class') {
96+
} else {
9297
hasAttrs = true
9398
attrs += `"${name}": (${JSON.stringify(attr.value)}),`
9499
}

src/observer/watcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Watcher.prototype.afterGet = function () {
188188
Watcher.prototype.update = function (shallow) {
189189
if (this.lazy) {
190190
this.dirty = true
191-
} else if (this.sync || !config.async) {
191+
} else if (this.sync) {
192192
this.run()
193193
} else {
194194
// if queued, only overwrite shallow with non-shallow,

0 commit comments

Comments
 (0)