File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
test/unit/modules/compiler Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ let platformGetTagNamespace
33
33
let platformMustUseProp
34
34
let preTransforms
35
35
let transforms
36
+ let postTransforms
36
37
let delimiters
37
38
38
39
/**
@@ -47,6 +48,7 @@ export function parse (
47
48
platformMustUseProp = options . mustUseProp || no
48
49
preTransforms = pluckModuleFunction ( options . modules , 'preTransformNode' )
49
50
transforms = pluckModuleFunction ( options . modules , 'transformNode' )
51
+ postTransforms = pluckModuleFunction ( options . modules , 'postTransformNode' )
50
52
delimiters = options . delimiters
51
53
const stack = [ ]
52
54
let root
@@ -165,6 +167,10 @@ export function parse (
165
167
currentParent = element
166
168
stack . push ( element )
167
169
}
170
+ // apply post-transforms
171
+ for ( let i = 0 ; i < postTransforms . length ; i ++ ) {
172
+ postTransforms [ i ] ( element , options )
173
+ }
168
174
} ,
169
175
170
176
end ( ) {
Original file line number Diff line number Diff line change @@ -316,15 +316,21 @@ describe('parser', () => {
316
316
expect ( ast . props ) . toBeUndefined ( )
317
317
} )
318
318
319
- it ( 'preTransforms ' , ( ) => {
319
+ it ( 'pre/post transforms ' , ( ) => {
320
320
const options = extend ( { } , baseOptions )
321
- const spy = jasmine . createSpy ( 'preTransform' )
321
+ const spy1 = jasmine . createSpy ( 'preTransform' )
322
+ const spy2 = jasmine . createSpy ( 'postTransform' )
322
323
options . modules = options . modules . concat ( [ {
323
324
preTransformNode ( el ) {
324
- spy ( el . tag )
325
+ spy1 ( el . tag )
326
+ } ,
327
+ postTransformNode ( el ) {
328
+ expect ( el . staticAttrs . length ) . toBe ( 1 )
329
+ spy2 ( el . tag )
325
330
}
326
331
} ] )
327
332
parse ( '<img v-pre src="hi">' , options )
328
- expect ( spy ) . toHaveBeenCalledWith ( 'img' )
333
+ expect ( spy1 ) . toHaveBeenCalledWith ( 'img' )
334
+ expect ( spy2 ) . toHaveBeenCalledWith ( 'img' )
329
335
} )
330
336
} )
You can’t perform that action at this time.
0 commit comments