File tree Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,12 @@ var XHTMLEntities = require('./xhtml');
5
5
var hexNumber = / ^ [ \d a - f A - F ] + $ / ;
6
6
var decimalNumber = / ^ \d + $ / ;
7
7
8
- module . exports = function ( acorn ) {
8
+ module . exports = function ( acorn , injectable ) {
9
+ if ( ! injectable ) {
10
+ injectable = acorn ;
11
+ acorn = require ( 'acorn' ) ;
12
+ }
13
+
9
14
var tt = acorn . tokTypes ;
10
15
var tc = acorn . tokContexts ;
11
16
@@ -359,7 +364,7 @@ module.exports = function(acorn) {
359
364
return this . jsx_parseElementAt ( startPos , startLoc ) ;
360
365
} ;
361
366
362
- acorn . plugins . jsx = function ( instance , opts ) {
367
+ var toInject = function ( instance , opts ) {
363
368
if ( ! opts ) {
364
369
return ;
365
370
}
@@ -429,5 +434,17 @@ module.exports = function(acorn) {
429
434
} ) ;
430
435
} ;
431
436
432
- return acorn ;
437
+ [ 'pluginsLoose' , 'plugins' ] . forEach ( function ( key ) {
438
+ if ( injectable [ key ] && ! injectable [ key ] . jsx ) {
439
+ injectable [ key ] . jsx = toInject ;
440
+ return ;
441
+ }
442
+
443
+ if ( acorn [ key ] && ! acorn [ key ] . jsx ) {
444
+ acorn [ key ] . jsx = toInject ;
445
+ return ;
446
+ }
447
+ } ) ;
448
+
449
+ return injectable ;
433
450
} ;
Original file line number Diff line number Diff line change 19
19
"test" : " node test/run.js"
20
20
},
21
21
"dependencies" : {
22
- "acorn" : " ^3 .0.4 "
22
+ "acorn" : " ^4 .0.2 "
23
23
},
24
24
"devDependencies" : {
25
- "chai" : " ^3.0 .0" ,
26
- "mocha" : " ^2.2.5 "
25
+ "chai" : " ^3.5 .0" ,
26
+ "mocha" : " ^3.0.2 "
27
27
}
28
28
}
You can’t perform that action at this time.
0 commit comments