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');
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
@@ -368,7 +373,7 @@ module.exports = function(acorn) {
368
373
return this . jsx_parseElementAt ( startPos , startLoc ) ;
369
374
} ;
370
375
371
- acorn . plugins . jsx = function ( instance , opts ) {
376
+ var toInject = function ( instance , opts ) {
372
377
if ( ! opts ) {
373
378
return ;
374
379
}
@@ -438,5 +443,17 @@ module.exports = function(acorn) {
438
443
} ) ;
439
444
} ;
440
445
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 ;
442
459
} ;
You can’t perform that action at this time.
0 commit comments