mirror of https://github.com/vuejs/vue.git
Changed checkbox -value to -exp, simplified matchValue
This commit is contained in:
parent
b027153d4a
commit
722094eefc
|
@ -5,8 +5,8 @@ module.exports = {
|
||||||
bind: function () {
|
bind: function () {
|
||||||
var self = this
|
var self = this
|
||||||
var el = this.el
|
var el = this.el
|
||||||
var trueExp = this._checkParam('true-value')
|
var trueExp = this._checkParam('true-exp')
|
||||||
var falseExp = this._checkParam('false-value')
|
var falseExp = this._checkParam('false-exp')
|
||||||
|
|
||||||
function getValue () {
|
function getValue () {
|
||||||
var val = el.checked
|
var val = el.checked
|
||||||
|
@ -22,21 +22,10 @@ module.exports = {
|
||||||
|
|
||||||
function matchValue (value) {
|
function matchValue (value) {
|
||||||
var trueValue = true
|
var trueValue = true
|
||||||
var falseValue = false
|
|
||||||
|
|
||||||
if (trueExp !== null) {
|
if (trueExp !== null) {
|
||||||
trueValue = self.vm.$eval(trueExp)
|
trueValue = self.vm.$eval(trueExp)
|
||||||
}
|
}
|
||||||
if (falseExp !== null) {
|
return trueValue === value
|
||||||
falseValue = self.vm.$eval(falseExp)
|
|
||||||
}
|
|
||||||
if (trueValue === value) {
|
|
||||||
return true
|
|
||||||
} else if (falseValue === value) {
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this._matchValue = matchValue
|
this._matchValue = matchValue
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ if (_.inBrowser) {
|
||||||
expect(vm.test).toBe(true)
|
expect(vm.test).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('checkbox true-value false-value', function (done) {
|
it('checkbox expression', function (done) {
|
||||||
var vm = new Vue({
|
var vm = new Vue({
|
||||||
el: el,
|
el: el,
|
||||||
data: {
|
data: {
|
||||||
|
@ -149,7 +149,7 @@ if (_.inBrowser) {
|
||||||
expression1: 'aTrueValue',
|
expression1: 'aTrueValue',
|
||||||
expression2: 'aFalseValue'
|
expression2: 'aFalseValue'
|
||||||
},
|
},
|
||||||
template: '<input type="checkbox" v-model="test" true-value="expression1" false-value="expression2">'
|
template: '<input type="checkbox" v-model="test" true-exp="expression1" false-exp="expression2">'
|
||||||
})
|
})
|
||||||
expect(vm.test).toBe('')
|
expect(vm.test).toBe('')
|
||||||
el.firstChild.click()
|
el.firstChild.click()
|
||||||
|
|
Loading…
Reference in New Issue