File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
test/unit/modules/compiler Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ const decodeHTMLCached = cached(decodeHTML)
31
31
let warn
32
32
let platformGetTagNamespace
33
33
let platformMustUseProp
34
+ let preTransforms
34
35
let transforms
35
36
let delimiters
36
37
@@ -44,6 +45,7 @@ export function parse (
44
45
warn = options . warn || baseWarn
45
46
platformGetTagNamespace = options . getTagNamespace || no
46
47
platformMustUseProp = options . mustUseProp || no
48
+ preTransforms = pluckModuleFunction ( options . modules , 'preTransformNode' )
47
49
transforms = pluckModuleFunction ( options . modules , 'transformNode' )
48
50
delimiters = options . delimiters
49
51
const stack = [ ]
@@ -97,6 +99,11 @@ export function parse (
97
99
)
98
100
}
99
101
102
+ // apply pre-transforms
103
+ for ( let i = 0 ; i < preTransforms . length ; i ++ ) {
104
+ preTransforms [ i ] ( element , options )
105
+ }
106
+
100
107
if ( ! inPre ) {
101
108
processPre ( element )
102
109
if ( element . pre ) {
Original file line number Diff line number Diff line change @@ -315,4 +315,16 @@ describe('parser', () => {
315
315
const ast = parse ( '<input type="text" name="field1" :value="msg">' , options )
316
316
expect ( ast . props ) . toBeUndefined ( )
317
317
} )
318
+
319
+ it ( 'preTransforms' , ( ) => {
320
+ const options = extend ( { } , baseOptions )
321
+ const spy = jasmine . createSpy ( 'preTransform' )
322
+ options . modules = options . modules . concat ( [ {
323
+ preTransformNode ( el ) {
324
+ spy ( el . tag )
325
+ }
326
+ } ] )
327
+ parse ( '<img v-pre src="hi">' , options )
328
+ expect ( spy ) . toHaveBeenCalledWith ( 'img' )
329
+ } )
318
330
} )
You can’t perform that action at this time.
0 commit comments