mirror of
https://github.com/vuejs/vue.git
synced 2024-11-21 20:28:54 +00:00
use more explicit naming
This commit is contained in:
parent
8c00a1d724
commit
7a4d30f62b
@ -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
|
||||
|
@ -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}",`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user