Explorar o código

$interpolate: coverage + cast to string on single token

Evan You %!s(int64=10) %!d(string=hai) anos
pai
achega
6858f5ca25
Modificáronse 2 ficheiros con 2 adicións e 1 borrados
  1. 1 1
      src/api/data.js
  2. 1 0
      test/unit/specs/api/data_spec.js

+ 1 - 1
src/api/data.js

@@ -121,7 +121,7 @@ exports.$interpolate = function (text) {
   var vm = this
   if (tokens) {
     if (tokens.length === 1) {
-      return vm.$eval(tokens[0].value)
+      return vm.$eval(tokens[0].value) + ''
     } else {
       return tokens.map(function (token) {
         return token.tag

+ 1 - 0
test/unit/specs/api/data_spec.js

@@ -151,6 +151,7 @@ describe('Data API', function () {
 
   it('$interpolate', function () {
     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')
   })