use more explicit naming

This commit is contained in:
Evan You 2016-04-11 22:18:04 -04:00
parent 8c00a1d724
commit 7a4d30f62b
2 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,4 @@
export function getAttr (el, attr) {
export function getAndRemoveAttr (el, attr) {
let val
if (val = el.attrsMap[attr]) {
el.attrsMap[attr] = null

View File

@ -2,7 +2,7 @@ import config from '../../config'
import { parseText } from '../text-parser'
import { genEvents, addHandler } from './events'
import { genModel } from './model'
import { getAttr } from './helpers'
import { getAndRemoveAttr } from './helpers'
const bindRE = /^:|^v-bind:/
const onRE = /^@|^v-on:/
@ -16,9 +16,9 @@ export function generate (ast) {
function genElement (el, key) {
let exp
if (exp = getAttr(el, 'v-for')) {
if (exp = getAndRemoveAttr(el, 'v-for')) {
return genFor(el, exp)
} else if (exp = getAttr(el, 'v-if')) {
} else if (exp = getAndRemoveAttr(el, 'v-if')) {
return genIf(el, exp)
} else if (el.tag === 'template') {
return genChildren(el)
@ -38,7 +38,7 @@ function genFor (el, exp) {
}
const alias = inMatch[1].trim()
exp = inMatch[2].trim()
let key = getAttr(el, 'track-by')
let key = getAndRemoveAttr(el, 'track-by')
if (!key) {
key ='undefined'
} else if (key !== '$index') {
@ -55,11 +55,11 @@ function genData (el, key) {
if (key) {
data += `key:${key},`
}
const classBinding = getAttr(el, ':class') || getAttr(el, 'v-bind:class')
const classBinding = getAndRemoveAttr(el, ':class') || getAndRemoveAttr(el, 'v-bind:class')
if (classBinding) {
data += `class: ${classBinding},`
}
const staticClass = getAttr(el, 'class')
const staticClass = getAndRemoveAttr(el, 'class')
if (staticClass) {
data += `staticClass: "${staticClass}",`
}