Просмотр исходного кода

fix two-way filter in attribute interpolations (fix #779)

Evan You 11 лет назад
Родитель
Сommit
d8335c25a6
2 измененных файлов с 3 добавлено и 2 удалено
  1. 2 1
      src/parsers/text.js
  2. 1 1
      test/unit/specs/parsers/text_spec.js

+ 2 - 1
src/parsers/text.js

@@ -169,7 +169,8 @@ function inlineFilters (exp) {
         var args = filter.args
           ? ',"' + filter.args.join('","') + '"'
           : ''
-        exp = 'this.$options.filters["' + filter.name + '"]' +
+        filter = 'this.$options.filters["' + filter.name + '"]'
+        exp = '(' + filter + '.read||' + filter + ')' +
           '.apply(this,[' + exp + args + '])'
       }
       return exp

+ 1 - 1
test/unit/specs/parsers/text_spec.js

@@ -119,7 +119,7 @@ describe('Text Parser', function () {
   it('tokens to expression with filters, multiple expressions', function () {
     var tokens = textParser.parse('a {{b | c d}} e')
     var exp = textParser.tokensToExp(tokens)
-    expect(exp).toBe('"a "+this.$options.filters["c"].apply(this,[b,"d"])+" e"')
+    expect(exp).toBe('"a "+(this.$options.filters["c"].read||this.$options.filters["c"]).apply(this,[b,"d"])+" e"')
   })
 
 })