Skip to content

Commit

Permalink
fix syncness
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 11, 2016
1 parent e094b00 commit ad11aa1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 15 additions & 10 deletions src/compiler/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ function genFor (el, exp) {
}
const alias = inMatch[1].trim()
exp = inMatch[2].trim()
const key = el.attrsMap['track-by'] || 'undefined'
return `(${exp}).map(function (${alias}, $index) {return ${genElement(el, key) }})`
let key = getAttr(el, 'track-by')
if (!key) {
key ='undefined'
} else if (key !== '$index') {
key = alias + '["' + key + '"]'
}
return `(${exp}).map(function (${alias}, $index) {return ${genElement(el, key)}})`
}

function genData (el, key) {
Expand All @@ -48,11 +53,13 @@ function genData (el, key) {
if (key) {
data += `key:${key},`
}
if (el.attrsMap[':class']) {
data += `class: ${el.attrsMap[':class']},`
const classBinding = getAttr(el, ':class') || getAttr(el, 'v-bind:class')
if (classBinding) {
data += `class: ${classBinding},`
}
if (el.attrsMap['class']) {
data += `staticClass: "${el.attrsMap['class']}"`
const staticClass = getAttr(el, 'class')
if (staticClass) {
data += `staticClass: "${staticClass}",`
}
let attrs = `attrs:{`
let props = `props:{`
Expand All @@ -66,9 +73,7 @@ function genData (el, key) {
let value = attr.value
if (bindRE.test(name)) {
name = name.replace(bindRE, '')
if (name === 'class') {
continue
} else if (name === 'style') {
if (name === 'style') {
data += `style: ${value},`
} else if (mustUsePropsRE.test(name)) {
hasProps = true
Expand All @@ -88,7 +93,7 @@ function genData (el, key) {
addHandler(events, 'input', `${value}=$event.target.value`)
} else if (dirRE.test(name)) {
// TODO: normal directives
} else if (name !== 'class') {
} else {
hasAttrs = true
attrs += `"${name}": (${JSON.stringify(attr.value)}),`
}
Expand Down
2 changes: 1 addition & 1 deletion src/observer/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Watcher.prototype.afterGet = function () {
Watcher.prototype.update = function (shallow) {
if (this.lazy) {
this.dirty = true
} else if (this.sync || !config.async) {
} else if (this.sync) {
this.run()
} else {
// if queued, only overwrite shallow with non-shallow,
Expand Down

0 comments on commit ad11aa1

Please sign in to comment.