File tree Expand file tree Collapse file tree 4 files changed +37
-1
lines changed Expand file tree Collapse file tree 4 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 1
1
/* @flow */
2
2
3
+ import { parseFilters } from './parser/filter-parser'
4
+
3
5
export function baseWarn ( msg : string ) {
4
6
console . error ( `[Vue parser]: ${ msg } ` )
5
7
}
@@ -72,7 +74,7 @@ export function getBindingAttr (
72
74
getAndRemoveAttr ( el , ':' + name ) ||
73
75
getAndRemoveAttr ( el , 'v-bind:' + name )
74
76
if ( dynamicValue != null ) {
75
- return dynamicValue
77
+ return parseFilters ( dynamicValue )
76
78
} else if ( getStatic !== false ) {
77
79
const staticValue = getAndRemoveAttr ( el , name )
78
80
if ( staticValue != null ) {
Original file line number Diff line number Diff line change 3
3
import { decode } from 'he'
4
4
import { parseHTML } from './html-parser'
5
5
import { parseText } from './text-parser'
6
+ import { parseFilters } from './filter-parser'
6
7
import { cached , no , camelize } from 'shared/util'
7
8
import { isIE , isServerRendering } from 'core/util/env'
8
9
import {
@@ -375,6 +376,7 @@ function processAttrs (el) {
375
376
}
376
377
if ( bindRE . test ( name ) ) { // v-bind
377
378
name = name . replace ( bindRE , '' )
379
+ value = parseFilters ( value )
378
380
if ( modifiers && modifiers . prop ) {
379
381
isProp = true
380
382
name = camelize ( name )
Original file line number Diff line number Diff line change @@ -29,6 +29,31 @@ describe('Filters', () => {
29
29
expect ( vm . $el . textContent ) . toBe ( 'IH' )
30
30
} )
31
31
32
+ it ( 'in v-bind' , ( ) => {
33
+ const vm = new Vue ( {
34
+ template : `
35
+ <div
36
+ v-bind:id="id | upper | reverse"
37
+ :class="cls | reverse"
38
+ :ref="ref | lower">
39
+ </div>
40
+ ` ,
41
+ filters : {
42
+ upper : v => v . toUpperCase ( ) ,
43
+ reverse : v => v . split ( '' ) . reverse ( ) . join ( '' ) ,
44
+ lower : v => v . toLowerCase ( )
45
+ } ,
46
+ data : {
47
+ id : 'abc' ,
48
+ cls : 'foo' ,
49
+ ref : 'BAR'
50
+ }
51
+ } ) . $mount ( )
52
+ expect ( vm . $el . id ) . toBe ( 'CBA' )
53
+ expect ( vm . $el . className ) . toBe ( 'oof' )
54
+ expect ( vm . $refs . bar ) . toBe ( vm . $el )
55
+ } )
56
+
32
57
it ( 'arguments' , ( ) => {
33
58
const vm = new Vue ( {
34
59
template : `<div>{{ msg | add(a, 3) }}</div>` ,
Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ describe('codegen', () => {
37
37
)
38
38
} )
39
39
40
+ it ( 'generate filters' , ( ) => {
41
+ assertCodegen (
42
+ '<div :id="a | b | c">{{ d | e | f }}</div>' ,
43
+ `with(this){return _h('div',{attrs:{"id":_f("c")(_f("b")(a))}},[_s(_f("f")(_f("e")(d)))])}`
44
+ )
45
+ } )
46
+
40
47
it ( 'generate v-for directive' , ( ) => {
41
48
assertCodegen (
42
49
'<li v-for="item in items" :key="item.uid"></li>' ,
You can’t perform that action at this time.
0 commit comments