mirror of https://github.com/vuejs/vue.git
$interpolate: coverage + cast to string on single token
This commit is contained in:
parent
ab9654b182
commit
92a62e8c2f
|
|
@ -119,7 +119,7 @@ exports.$interpolate = function (text) {
|
||||||
var vm = this
|
var vm = this
|
||||||
if (tokens) {
|
if (tokens) {
|
||||||
if (tokens.length === 1) {
|
if (tokens.length === 1) {
|
||||||
return vm.$eval(tokens[0].value)
|
return vm.$eval(tokens[0].value) + ''
|
||||||
} else {
|
} else {
|
||||||
return tokens.map(function (token) {
|
return tokens.map(function (token) {
|
||||||
return token.tag
|
return token.tag
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,7 @@ describe('Data API', function () {
|
||||||
|
|
||||||
it('$interpolate', function () {
|
it('$interpolate', function () {
|
||||||
expect(vm.$interpolate('abc')).toBe('abc')
|
expect(vm.$interpolate('abc')).toBe('abc')
|
||||||
|
expect(vm.$interpolate('{{a}}')).toBe('1')
|
||||||
expect(vm.$interpolate('{{a}} and {{a + b.c | double}}')).toBe('1 and 6')
|
expect(vm.$interpolate('{{a}} and {{a + b.c | double}}')).toBe('1 and 6')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue