11var utils = require ( './utils' ) ,
2- directives = require ( './directives' ) ,
32 dirId = 1 ,
43
54 // Regexes!
6-
75 // regex to split multiple directive expressions
86 // split by commas, but ignore commas within quotes, parens and escapes.
97 SPLIT_RE = / (?: [ ' " ] (?: \\ .| [ ^ ' " ] ) * [ ' " ] | \( (?: \\ .| [ ^ \) ] ) * \) | \\ .| [ ^ , ] ) + / g,
10-
118 // match up to the first single pipe, ignore those within quotes.
129 KEY_RE = / ^ (?: [ ' " ] (?: \\ .| [ ^ ' " ] ) * [ ' " ] | \\ .| [ ^ \| ] | \| \| ) + / ,
13-
1410 ARG_RE = / ^ ( [ \w - $ ] + ) : ( .+ ) $ / ,
1511 FILTERS_RE = / \| [ ^ \| ] + / g,
1612 FILTER_TOKEN_RE = / [ ^ \s ' ] + | ' [ ^ ' ] + ' | [ ^ \s " ] + | " [ ^ " ] + " / g,
@@ -63,7 +59,7 @@ function Directive (dirname, definition, expression, rawKey, compiler, node) {
6359 this . arg = parsed . arg
6460
6561 var filters = Directive . parseFilters ( this . expression . slice ( rawKey . length ) ) ,
66- filter , fn , i , l
62+ filter , fn , i , l , computed
6763 if ( filters ) {
6864 this . filters = [ ]
6965 for ( i = 0 , l = filters . length ; i < l ; i ++ ) {
@@ -73,7 +69,7 @@ function Directive (dirname, definition, expression, rawKey, compiler, node) {
7369 filter . apply = fn
7470 this . filters . push ( filter )
7571 if ( fn . computed ) {
76- this . computeFilters = true
72+ computed = true
7773 }
7874 }
7975 }
@@ -83,12 +79,13 @@ function Directive (dirname, definition, expression, rawKey, compiler, node) {
8379 this . filters = null
8480 }
8581
86- if ( this . computeFilters ) {
87- this . key = Directive . inlineFilters ( this . key , this . filters )
82+ if ( computed ) {
83+ this . computedKey = Directive . inlineFilters ( this . key , this . filters )
84+ this . filters = null
8885 }
8986
9087 this . isExp =
91- this . computeFilters ||
88+ computed ||
9289 ! SINGLE_VAR_RE . test ( this . key ) ||
9390 NESTING_RE . test ( this . key )
9491
@@ -174,7 +171,9 @@ Directive.parseArg = function (rawKey) {
174171 * parse a the filters
175172 */
176173Directive . parseFilters = function ( exp ) {
177- if ( ! exp . indexOf ( '|' ) < 0 ) return
174+ if ( exp . indexOf ( '|' ) < 0 ) {
175+ return
176+ }
178177 var filters = exp . match ( FILTERS_RE ) ,
179178 res , i , l , tokens
180179 if ( filters ) {
0 commit comments