@@ -71,6 +71,26 @@ var lookahead,
71
71
extra ,
72
72
lastToken ;
73
73
74
+ /**
75
+ * Object.assign polyfill for Node < 4
76
+ * @param {Object } target The target object
77
+ * @param {...Object } sources Sources for the object
78
+ * @returns {Object } `target` after being mutated
79
+ */
80
+ var assign = Object . assign || function assign ( target ) {
81
+ for ( var argIndex = 1 ; argIndex < arguments . length ; argIndex ++ ) {
82
+ if ( arguments [ argIndex ] !== null && typeof arguments [ argIndex ] === "object" ) {
83
+ var keys = Object . keys ( arguments [ argIndex ] ) ;
84
+
85
+ for ( var keyIndex = 0 ; keyIndex < keys . length ; keyIndex ++ ) {
86
+ target [ keys [ keyIndex ] ] = arguments [ argIndex ] [ keys [ keyIndex ] ] ;
87
+ }
88
+ }
89
+ }
90
+
91
+ return target ;
92
+ } ;
93
+
74
94
/**
75
95
* Resets the extra object to its default.
76
96
* @returns {void }
@@ -515,7 +535,7 @@ function tokenize(code, options) {
515
535
lookahead = null ;
516
536
517
537
// Options matching.
518
- options = options || { } ;
538
+ options = assign ( { } , options ) ;
519
539
520
540
var acornOptions = {
521
541
ecmaVersion : DEFAULT_ECMA_VERSION ,
@@ -551,7 +571,7 @@ function tokenize(code, options) {
551
571
552
572
// apply parsing flags
553
573
if ( options . ecmaFeatures && typeof options . ecmaFeatures === "object" ) {
554
- extra . ecmaFeatures = options . ecmaFeatures ;
574
+ extra . ecmaFeatures = assign ( { } , options . ecmaFeatures ) ;
555
575
impliedStrict = extra . ecmaFeatures . impliedStrict ;
556
576
extra . ecmaFeatures . impliedStrict = typeof impliedStrict === "boolean" && impliedStrict ;
557
577
}
@@ -687,7 +707,7 @@ function parse(code, options) {
687
707
688
708
// apply parsing flags after sourceType to allow overriding
689
709
if ( options . ecmaFeatures && typeof options . ecmaFeatures === "object" ) {
690
- extra . ecmaFeatures = options . ecmaFeatures ;
710
+ extra . ecmaFeatures = assign ( { } , options . ecmaFeatures ) ;
691
711
impliedStrict = extra . ecmaFeatures . impliedStrict ;
692
712
extra . ecmaFeatures . impliedStrict = typeof impliedStrict === "boolean" && impliedStrict ;
693
713
if ( options . ecmaFeatures . globalReturn ) {
0 commit comments