File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
Expand file tree Collapse file tree 1 file changed +20
-3
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
@@ -368,7 +373,7 @@ module.exports = function(acorn) {
368373 return this . jsx_parseElementAt ( startPos , startLoc ) ;
369374 } ;
370375
371- acorn . plugins . jsx = function ( instance , opts ) {
376+ var toInject = function ( instance , opts ) {
372377 if ( ! opts ) {
373378 return ;
374379 }
@@ -438,5 +443,17 @@ module.exports = function(acorn) {
438443 } ) ;
439444 } ;
440445
441- return acorn ;
446+ [ 'pluginsLoose' , 'plugins' ] . forEach ( function ( key ) {
447+ if ( injectable [ key ] && ! injectable [ key ] . jsx ) {
448+ injectable [ key ] . jsx = toInject ;
449+ return ;
450+ }
451+
452+ if ( acorn [ key ] && ! acorn [ key ] . jsx ) {
453+ acorn [ key ] . jsx = toInject ;
454+ return ;
455+ }
456+ } ) ;
457+
458+ return injectable ;
442459} ;
You can’t perform that action at this time.
0 commit comments