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');
55var hexNumber = / ^ [ \d a - f A - F ] + $ / ;
66var decimalNumber = / ^ \d + $ / ;
77
8- module . exports = function ( acorn ) {
8+ module . exports = function ( acorn , injectable ) {
9+ if ( ! injectable ) {
10+ injectable = acorn ;
11+ acorn = require ( 'acorn' ) ;
12+ }
13+
914 var tt = acorn . tokTypes ;
1015 var tc = acorn . tokContexts ;
1116
@@ -359,7 +364,7 @@ module.exports = function(acorn) {
359364 return this . jsx_parseElementAt ( startPos , startLoc ) ;
360365 } ;
361366
362- acorn . plugins . jsx = function ( instance , opts ) {
367+ var toInject = function ( instance , opts ) {
363368 if ( ! opts ) {
364369 return ;
365370 }
@@ -429,5 +434,17 @@ module.exports = function(acorn) {
429434 } ) ;
430435 } ;
431436
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 ;
433450} ;
Original file line number Diff line number Diff line change 1919 "test" : " node test/run.js"
2020 },
2121 "dependencies" : {
22- "acorn" : " ^3 .0.4 "
22+ "acorn" : " ^4 .0.2 "
2323 },
2424 "devDependencies" : {
25- "chai" : " ^3.0 .0" ,
26- "mocha" : " ^2.2.5 "
25+ "chai" : " ^3.5 .0" ,
26+ "mocha" : " ^3.0.2 "
2727 }
2828}
You can’t perform that action at this time.
0 commit comments