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
@@ -376,7 +381,7 @@ module.exports = function(acorn) {
376
381
return this . jsx_parseElementAt ( startPos , startLoc ) ;
377
382
} ;
378
383
379
- acorn . plugins . jsx = function ( instance , opts ) {
384
+ var toInject = function ( instance , opts ) {
380
385
if ( ! opts ) {
381
386
return ;
382
387
}
@@ -446,5 +451,17 @@ module.exports = function(acorn) {
446
451
} ) ;
447
452
} ;
448
453
449
- return acorn ;
454
+ [ 'pluginsLoose' , 'plugins' ] . forEach ( function ( key ) {
455
+ if ( injectable [ key ] && ! injectable [ key ] . jsx ) {
456
+ injectable [ key ] . jsx = toInject ;
457
+ return ;
458
+ }
459
+
460
+ if ( acorn [ key ] && ! acorn [ key ] . jsx ) {
461
+ acorn [ key ] . jsx = toInject ;
462
+ return ;
463
+ }
464
+ } ) ;
465
+
466
+ return injectable ;
450
467
} ;
You can’t perform that action at this time.
0 commit comments