adjust binding attr retrieval priority

This commit is contained in:
Evan You 2016-05-26 13:23:05 -04:00
parent 69abe1b726
commit 20f6e6e3fe

View File

@ -70,14 +70,21 @@ export function getBindingAttr (
el: ASTElement,
name: string,
getStatic?: boolean
) {
const staticValue = getStatic !== false && getAndRemoveAttr(el, name)
return staticValue || staticValue === ''
? JSON.stringify(staticValue)
: (getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name))
): ?string {
const dynamicValue =
getAndRemoveAttr(el, ':' + name) ||
getAndRemoveAttr(el, 'v-bind:' + name)
if (dynamicValue != null) {
return dynamicValue
} else if (getStatic !== false) {
const staticValue = getAndRemoveAttr(el, name)
if (staticValue != null) {
return JSON.stringify(staticValue)
}
}
}
export function getAndRemoveAttr (el: ASTElement, name: string) {
export function getAndRemoveAttr (el: ASTElement, name: string): ?string {
let val
if ((val = el.attrsMap[name]) != null) {
el.attrsMap[name] = null