react 0.13.0-rc1 → 0.13.0-rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/JSXTransformer.js +708 -792
- package/dist/react-with-addons.js +133 -46
- package/dist/react-with-addons.min.js +5 -5
- package/dist/react.js +132 -45
- package/dist/react.min.js +4 -4
- package/lib/React.js +4 -1
- package/lib/ReactCompositeComponent.js +6 -4
- package/lib/ReactElement.js +54 -0
- package/lib/ReactElementValidator.js +61 -35
- package/lib/ReactFragment.js +2 -1
- package/lib/ReactPropTypes.js +2 -0
- package/lib/ReactReconciler.js +0 -1
- package/lib/ReactRef.js +1 -1
- package/lib/cloneWithProps.js +1 -1
- package/package.json +1 -1
package/dist/JSXTransformer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JSXTransformer v0.13.0-
|
|
2
|
+
* JSXTransformer v0.13.0-rc2
|
|
3
3
|
*/
|
|
4
4
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.JSXTransformer = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
|
5
5
|
/**
|
|
@@ -2314,32 +2314,6 @@ process.umask = function() { return 0; };
|
|
|
2314
2314
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2315
2315
|
*/
|
|
2316
2316
|
|
|
2317
|
-
/*jslint bitwise:true plusplus:true */
|
|
2318
|
-
/*global esprima:true, define:true, exports:true, window: true,
|
|
2319
|
-
throwErrorTolerant: true,
|
|
2320
|
-
throwError: true, generateStatement: true, peek: true,
|
|
2321
|
-
parseAssignmentExpression: true, parseBlock: true,
|
|
2322
|
-
parseClassExpression: true, parseClassDeclaration: true, parseExpression: true,
|
|
2323
|
-
parseDeclareClass: true, parseDeclareFunction: true,
|
|
2324
|
-
parseDeclareModule: true, parseDeclareVariable: true,
|
|
2325
|
-
parseForStatement: true,
|
|
2326
|
-
parseFunctionDeclaration: true, parseFunctionExpression: true,
|
|
2327
|
-
parseFunctionSourceElements: true, parseVariableIdentifier: true,
|
|
2328
|
-
parseImportSpecifier: true, parseInterface: true,
|
|
2329
|
-
parseLeftHandSideExpression: true, parseParams: true, validateParam: true,
|
|
2330
|
-
parseSpreadOrAssignmentExpression: true,
|
|
2331
|
-
parseStatement: true, parseSourceElement: true, parseConciseBody: true,
|
|
2332
|
-
advanceXJSChild: true, isXJSIdentifierStart: true, isXJSIdentifierPart: true,
|
|
2333
|
-
scanXJSStringLiteral: true, scanXJSIdentifier: true,
|
|
2334
|
-
parseXJSAttributeValue: true, parseXJSChild: true, parseXJSElement: true, parseXJSExpressionContainer: true, parseXJSEmptyExpression: true,
|
|
2335
|
-
parseFunctionTypeParam: true,
|
|
2336
|
-
parsePrimaryType: true,
|
|
2337
|
-
parseTypeAlias: true,
|
|
2338
|
-
parseType: true, parseTypeAnnotatableIdentifier: true, parseTypeAnnotation: true,
|
|
2339
|
-
parseTypeParameterDeclaration: true,
|
|
2340
|
-
parseYieldExpression: true, parseAwaitExpression: true
|
|
2341
|
-
*/
|
|
2342
|
-
|
|
2343
2317
|
(function (root, factory) {
|
|
2344
2318
|
'use strict';
|
|
2345
2319
|
|
|
@@ -2389,8 +2363,8 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
2389
2363
|
StringLiteral: 8,
|
|
2390
2364
|
RegularExpression: 9,
|
|
2391
2365
|
Template: 10,
|
|
2392
|
-
|
|
2393
|
-
|
|
2366
|
+
JSXIdentifier: 11,
|
|
2367
|
+
JSXText: 12
|
|
2394
2368
|
};
|
|
2395
2369
|
|
|
2396
2370
|
TokenName = {};
|
|
@@ -2402,8 +2376,8 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
2402
2376
|
TokenName[Token.NumericLiteral] = 'Numeric';
|
|
2403
2377
|
TokenName[Token.Punctuator] = 'Punctuator';
|
|
2404
2378
|
TokenName[Token.StringLiteral] = 'String';
|
|
2405
|
-
TokenName[Token.
|
|
2406
|
-
TokenName[Token.
|
|
2379
|
+
TokenName[Token.JSXIdentifier] = 'JSXIdentifier';
|
|
2380
|
+
TokenName[Token.JSXText] = 'JSXText';
|
|
2407
2381
|
TokenName[Token.RegularExpression] = 'RegularExpression';
|
|
2408
2382
|
|
|
2409
2383
|
// A function following one of those tokens is an expression.
|
|
@@ -2514,17 +2488,17 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
2514
2488
|
VoidTypeAnnotation: 'VoidTypeAnnotation',
|
|
2515
2489
|
WhileStatement: 'WhileStatement',
|
|
2516
2490
|
WithStatement: 'WithStatement',
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2491
|
+
JSXIdentifier: 'JSXIdentifier',
|
|
2492
|
+
JSXNamespacedName: 'JSXNamespacedName',
|
|
2493
|
+
JSXMemberExpression: 'JSXMemberExpression',
|
|
2494
|
+
JSXEmptyExpression: 'JSXEmptyExpression',
|
|
2495
|
+
JSXExpressionContainer: 'JSXExpressionContainer',
|
|
2496
|
+
JSXElement: 'JSXElement',
|
|
2497
|
+
JSXClosingElement: 'JSXClosingElement',
|
|
2498
|
+
JSXOpeningElement: 'JSXOpeningElement',
|
|
2499
|
+
JSXAttribute: 'JSXAttribute',
|
|
2500
|
+
JSXSpreadAttribute: 'JSXSpreadAttribute',
|
|
2501
|
+
JSXText: 'JSXText',
|
|
2528
2502
|
YieldExpression: 'YieldExpression',
|
|
2529
2503
|
AwaitExpression: 'AwaitExpression'
|
|
2530
2504
|
};
|
|
@@ -2542,32 +2516,33 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
2542
2516
|
|
|
2543
2517
|
// Error messages should be identical to V8.
|
|
2544
2518
|
Messages = {
|
|
2545
|
-
UnexpectedToken:
|
|
2546
|
-
UnexpectedNumber:
|
|
2547
|
-
UnexpectedString:
|
|
2548
|
-
UnexpectedIdentifier:
|
|
2549
|
-
UnexpectedReserved:
|
|
2550
|
-
UnexpectedTemplate:
|
|
2551
|
-
UnexpectedEOS:
|
|
2552
|
-
NewlineAfterThrow:
|
|
2519
|
+
UnexpectedToken: 'Unexpected token %0',
|
|
2520
|
+
UnexpectedNumber: 'Unexpected number',
|
|
2521
|
+
UnexpectedString: 'Unexpected string',
|
|
2522
|
+
UnexpectedIdentifier: 'Unexpected identifier',
|
|
2523
|
+
UnexpectedReserved: 'Unexpected reserved word',
|
|
2524
|
+
UnexpectedTemplate: 'Unexpected quasi %0',
|
|
2525
|
+
UnexpectedEOS: 'Unexpected end of input',
|
|
2526
|
+
NewlineAfterThrow: 'Illegal newline after throw',
|
|
2553
2527
|
InvalidRegExp: 'Invalid regular expression',
|
|
2554
|
-
UnterminatedRegExp:
|
|
2555
|
-
InvalidLHSInAssignment:
|
|
2556
|
-
InvalidLHSInFormalsList:
|
|
2557
|
-
InvalidLHSInForIn:
|
|
2528
|
+
UnterminatedRegExp: 'Invalid regular expression: missing /',
|
|
2529
|
+
InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
|
|
2530
|
+
InvalidLHSInFormalsList: 'Invalid left-hand side in formals list',
|
|
2531
|
+
InvalidLHSInForIn: 'Invalid left-hand side in for-in',
|
|
2558
2532
|
MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
|
|
2559
|
-
NoCatchOrFinally:
|
|
2533
|
+
NoCatchOrFinally: 'Missing catch or finally after try',
|
|
2560
2534
|
UnknownLabel: 'Undefined label \'%0\'',
|
|
2561
2535
|
Redeclaration: '%0 \'%1\' has already been declared',
|
|
2562
2536
|
IllegalContinue: 'Illegal continue statement',
|
|
2563
2537
|
IllegalBreak: 'Illegal break statement',
|
|
2564
2538
|
IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition',
|
|
2539
|
+
IllegalClassConstructorProperty: 'Illegal constructor property in class definition',
|
|
2565
2540
|
IllegalReturn: 'Illegal return statement',
|
|
2566
2541
|
IllegalSpread: 'Illegal spread element',
|
|
2567
|
-
StrictModeWith:
|
|
2568
|
-
StrictCatchVariable:
|
|
2569
|
-
StrictVarName:
|
|
2570
|
-
StrictParamName:
|
|
2542
|
+
StrictModeWith: 'Strict mode code may not include a with statement',
|
|
2543
|
+
StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
|
|
2544
|
+
StrictVarName: 'Variable name may not be eval or arguments in strict mode',
|
|
2545
|
+
StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
|
|
2571
2546
|
StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
|
|
2572
2547
|
ParameterAfterRestParameter: 'Rest parameter must be final parameter of an argument list',
|
|
2573
2548
|
DefaultRestParameter: 'Rest parameter can not have a default value',
|
|
@@ -2575,28 +2550,28 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
2575
2550
|
PropertyAfterSpreadProperty: 'A rest property must be the final property of an object literal',
|
|
2576
2551
|
ObjectPatternAsRestParameter: 'Invalid rest parameter',
|
|
2577
2552
|
ObjectPatternAsSpread: 'Invalid spread argument',
|
|
2578
|
-
StrictFunctionName:
|
|
2579
|
-
StrictOctalLiteral:
|
|
2580
|
-
StrictDelete:
|
|
2581
|
-
StrictDuplicateProperty:
|
|
2582
|
-
AccessorDataProperty:
|
|
2583
|
-
AccessorGetSet:
|
|
2584
|
-
StrictLHSAssignment:
|
|
2585
|
-
StrictLHSPostfix:
|
|
2586
|
-
StrictLHSPrefix:
|
|
2587
|
-
StrictReservedWord:
|
|
2553
|
+
StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
|
|
2554
|
+
StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
|
|
2555
|
+
StrictDelete: 'Delete of an unqualified identifier in strict mode.',
|
|
2556
|
+
StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode',
|
|
2557
|
+
AccessorDataProperty: 'Object literal may not have data and accessor property with the same name',
|
|
2558
|
+
AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name',
|
|
2559
|
+
StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
|
|
2560
|
+
StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
|
|
2561
|
+
StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
|
|
2562
|
+
StrictReservedWord: 'Use of future reserved word in strict mode',
|
|
2588
2563
|
MissingFromClause: 'Missing from clause',
|
|
2589
2564
|
NoAsAfterImportNamespace: 'Missing as after import *',
|
|
2590
2565
|
InvalidModuleSpecifier: 'Invalid module specifier',
|
|
2591
2566
|
IllegalImportDeclaration: 'Illegal import declaration',
|
|
2592
2567
|
IllegalExportDeclaration: 'Illegal export declaration',
|
|
2593
|
-
|
|
2568
|
+
NoUninitializedConst: 'Const must be initialized',
|
|
2594
2569
|
ComprehensionRequiresBlock: 'Comprehension must have at least one block',
|
|
2595
|
-
ComprehensionError:
|
|
2596
|
-
EachNotAllowed:
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2570
|
+
ComprehensionError: 'Comprehension Error',
|
|
2571
|
+
EachNotAllowed: 'Each is not supported',
|
|
2572
|
+
InvalidJSXAttributeValue: 'JSX value should be either an expression or a quoted JSX text',
|
|
2573
|
+
ExpectedJSXClosingTag: 'Expected corresponding JSX closing tag for %0',
|
|
2574
|
+
AdjacentJSXElements: 'Adjacent JSX elements must be wrapped in an enclosing tag',
|
|
2600
2575
|
ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' +
|
|
2601
2576
|
'you are trying to write a function type, but you ended up ' +
|
|
2602
2577
|
'writing a grouped type followed by an =>, which is a syntax ' +
|
|
@@ -2644,7 +2619,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
2644
2619
|
return Object.prototype.hasOwnProperty.call(this.$data, key);
|
|
2645
2620
|
};
|
|
2646
2621
|
|
|
2647
|
-
StringMap.prototype[
|
|
2622
|
+
StringMap.prototype["delete"] = function (key) {
|
|
2648
2623
|
key = '$' + key;
|
|
2649
2624
|
return delete this.$data[key];
|
|
2650
2625
|
};
|
|
@@ -2776,69 +2751,134 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
2776
2751
|
|
|
2777
2752
|
// 7.4 Comments
|
|
2778
2753
|
|
|
2779
|
-
function
|
|
2780
|
-
var
|
|
2754
|
+
function addComment(type, value, start, end, loc) {
|
|
2755
|
+
var comment;
|
|
2756
|
+
assert(typeof start === 'number', 'Comment must have valid position');
|
|
2757
|
+
|
|
2758
|
+
// Because the way the actual token is scanned, often the comments
|
|
2759
|
+
// (if any) are skipped twice during the lexical analysis.
|
|
2760
|
+
// Thus, we need to skip adding a comment if the comment array already
|
|
2761
|
+
// handled it.
|
|
2762
|
+
if (state.lastCommentStart >= start) {
|
|
2763
|
+
return;
|
|
2764
|
+
}
|
|
2765
|
+
state.lastCommentStart = start;
|
|
2766
|
+
|
|
2767
|
+
comment = {
|
|
2768
|
+
type: type,
|
|
2769
|
+
value: value
|
|
2770
|
+
};
|
|
2771
|
+
if (extra.range) {
|
|
2772
|
+
comment.range = [start, end];
|
|
2773
|
+
}
|
|
2774
|
+
if (extra.loc) {
|
|
2775
|
+
comment.loc = loc;
|
|
2776
|
+
}
|
|
2777
|
+
extra.comments.push(comment);
|
|
2778
|
+
if (extra.attachComment) {
|
|
2779
|
+
extra.leadingComments.push(comment);
|
|
2780
|
+
extra.trailingComments.push(comment);
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2781
2783
|
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
+
function skipSingleLineComment() {
|
|
2785
|
+
var start, loc, ch, comment;
|
|
2786
|
+
|
|
2787
|
+
start = index - 2;
|
|
2788
|
+
loc = {
|
|
2789
|
+
start: {
|
|
2790
|
+
line: lineNumber,
|
|
2791
|
+
column: index - lineStart - 2
|
|
2792
|
+
}
|
|
2793
|
+
};
|
|
2784
2794
|
|
|
2785
2795
|
while (index < length) {
|
|
2786
2796
|
ch = source.charCodeAt(index);
|
|
2797
|
+
++index;
|
|
2798
|
+
if (isLineTerminator(ch)) {
|
|
2799
|
+
if (extra.comments) {
|
|
2800
|
+
comment = source.slice(start + 2, index - 1);
|
|
2801
|
+
loc.end = {
|
|
2802
|
+
line: lineNumber,
|
|
2803
|
+
column: index - lineStart - 1
|
|
2804
|
+
};
|
|
2805
|
+
addComment('Line', comment, start, index - 1, loc);
|
|
2806
|
+
}
|
|
2807
|
+
if (ch === 13 && source.charCodeAt(index) === 10) {
|
|
2808
|
+
++index;
|
|
2809
|
+
}
|
|
2810
|
+
++lineNumber;
|
|
2811
|
+
lineStart = index;
|
|
2812
|
+
return;
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2787
2815
|
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2816
|
+
if (extra.comments) {
|
|
2817
|
+
comment = source.slice(start + 2, index);
|
|
2818
|
+
loc.end = {
|
|
2819
|
+
line: lineNumber,
|
|
2820
|
+
column: index - lineStart
|
|
2821
|
+
};
|
|
2822
|
+
addComment('Line', comment, start, index, loc);
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
|
|
2826
|
+
function skipMultiLineComment() {
|
|
2827
|
+
var start, loc, ch, comment;
|
|
2828
|
+
|
|
2829
|
+
if (extra.comments) {
|
|
2830
|
+
start = index - 2;
|
|
2831
|
+
loc = {
|
|
2832
|
+
start: {
|
|
2833
|
+
line: lineNumber,
|
|
2834
|
+
column: index - lineStart - 2
|
|
2797
2835
|
}
|
|
2798
|
-
}
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
lineStart = index;
|
|
2807
|
-
if (index >= length) {
|
|
2808
|
-
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
2809
|
-
}
|
|
2810
|
-
}
|
|
2811
|
-
} else {
|
|
2812
|
-
ch = source.charCodeAt(index++);
|
|
2813
|
-
if (index >= length) {
|
|
2814
|
-
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
2815
|
-
}
|
|
2816
|
-
// Block comment ends with '*/' (char #42, char #47).
|
|
2817
|
-
if (ch === 42) {
|
|
2818
|
-
ch = source.charCodeAt(index);
|
|
2819
|
-
if (ch === 47) {
|
|
2820
|
-
++index;
|
|
2821
|
-
blockComment = false;
|
|
2822
|
-
}
|
|
2823
|
-
}
|
|
2836
|
+
};
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
while (index < length) {
|
|
2840
|
+
ch = source.charCodeAt(index);
|
|
2841
|
+
if (isLineTerminator(ch)) {
|
|
2842
|
+
if (ch === 13 && source.charCodeAt(index + 1) === 10) {
|
|
2843
|
+
++index;
|
|
2824
2844
|
}
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
if (
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2845
|
+
++lineNumber;
|
|
2846
|
+
++index;
|
|
2847
|
+
lineStart = index;
|
|
2848
|
+
if (index >= length) {
|
|
2849
|
+
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
2850
|
+
}
|
|
2851
|
+
} else if (ch === 42) {
|
|
2852
|
+
// Block comment ends with '*/' (char #42, char #47).
|
|
2853
|
+
if (source.charCodeAt(index + 1) === 47) {
|
|
2854
|
+
++index;
|
|
2855
|
+
++index;
|
|
2856
|
+
if (extra.comments) {
|
|
2857
|
+
comment = source.slice(start + 2, index - 2);
|
|
2858
|
+
loc.end = {
|
|
2859
|
+
line: lineNumber,
|
|
2860
|
+
column: index - lineStart
|
|
2861
|
+
};
|
|
2862
|
+
addComment('Block', comment, start, index, loc);
|
|
2837
2863
|
}
|
|
2838
|
-
|
|
2839
|
-
break;
|
|
2864
|
+
return;
|
|
2840
2865
|
}
|
|
2841
|
-
|
|
2866
|
+
++index;
|
|
2867
|
+
} else {
|
|
2868
|
+
++index;
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
function skipComment() {
|
|
2876
|
+
var ch;
|
|
2877
|
+
|
|
2878
|
+
while (index < length) {
|
|
2879
|
+
ch = source.charCodeAt(index);
|
|
2880
|
+
|
|
2881
|
+
if (isWhiteSpace(ch)) {
|
|
2842
2882
|
++index;
|
|
2843
2883
|
} else if (isLineTerminator(ch)) {
|
|
2844
2884
|
++index;
|
|
@@ -2847,6 +2887,19 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
2847
2887
|
}
|
|
2848
2888
|
++lineNumber;
|
|
2849
2889
|
lineStart = index;
|
|
2890
|
+
} else if (ch === 47) { // 47 is '/'
|
|
2891
|
+
ch = source.charCodeAt(index + 1);
|
|
2892
|
+
if (ch === 47) {
|
|
2893
|
+
++index;
|
|
2894
|
+
++index;
|
|
2895
|
+
skipSingleLineComment();
|
|
2896
|
+
} else if (ch === 42) { // 42 is '*'
|
|
2897
|
+
++index;
|
|
2898
|
+
++index;
|
|
2899
|
+
skipMultiLineComment();
|
|
2900
|
+
} else {
|
|
2901
|
+
break;
|
|
2902
|
+
}
|
|
2850
2903
|
} else {
|
|
2851
2904
|
break;
|
|
2852
2905
|
}
|
|
@@ -3009,7 +3062,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3009
3062
|
ch3,
|
|
3010
3063
|
ch4;
|
|
3011
3064
|
|
|
3012
|
-
if (state.
|
|
3065
|
+
if (state.inJSXTag || state.inJSXChild) {
|
|
3013
3066
|
// Don't need to check for '{' and '}' as it's already handled
|
|
3014
3067
|
// correctly by default.
|
|
3015
3068
|
switch (code) {
|
|
@@ -3249,6 +3302,41 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3249
3302
|
};
|
|
3250
3303
|
}
|
|
3251
3304
|
|
|
3305
|
+
function scanBinaryLiteral(start) {
|
|
3306
|
+
var ch, number;
|
|
3307
|
+
|
|
3308
|
+
number = '';
|
|
3309
|
+
|
|
3310
|
+
while (index < length) {
|
|
3311
|
+
ch = source[index];
|
|
3312
|
+
if (ch !== '0' && ch !== '1') {
|
|
3313
|
+
break;
|
|
3314
|
+
}
|
|
3315
|
+
number += source[index++];
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3318
|
+
if (number.length === 0) {
|
|
3319
|
+
// only 0b or 0B
|
|
3320
|
+
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3323
|
+
if (index < length) {
|
|
3324
|
+
ch = source.charCodeAt(index);
|
|
3325
|
+
/* istanbul ignore else */
|
|
3326
|
+
if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
|
|
3327
|
+
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
return {
|
|
3332
|
+
type: Token.NumericLiteral,
|
|
3333
|
+
value: parseInt(number, 2),
|
|
3334
|
+
lineNumber: lineNumber,
|
|
3335
|
+
lineStart: lineStart,
|
|
3336
|
+
range: [start, index]
|
|
3337
|
+
};
|
|
3338
|
+
}
|
|
3339
|
+
|
|
3252
3340
|
function scanOctalLiteral(prefix, start) {
|
|
3253
3341
|
var number, octal;
|
|
3254
3342
|
|
|
@@ -3288,7 +3376,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3288
3376
|
}
|
|
3289
3377
|
|
|
3290
3378
|
function scanNumericLiteral() {
|
|
3291
|
-
var number, start, ch
|
|
3379
|
+
var number, start, ch;
|
|
3292
3380
|
|
|
3293
3381
|
ch = source[index];
|
|
3294
3382
|
assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'),
|
|
@@ -3311,35 +3399,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3311
3399
|
}
|
|
3312
3400
|
if (ch === 'b' || ch === 'B') {
|
|
3313
3401
|
++index;
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
while (index < length) {
|
|
3317
|
-
ch = source[index];
|
|
3318
|
-
if (ch !== '0' && ch !== '1') {
|
|
3319
|
-
break;
|
|
3320
|
-
}
|
|
3321
|
-
number += source[index++];
|
|
3322
|
-
}
|
|
3323
|
-
|
|
3324
|
-
if (number.length === 0) {
|
|
3325
|
-
// only 0b or 0B
|
|
3326
|
-
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
3327
|
-
}
|
|
3328
|
-
|
|
3329
|
-
if (index < length) {
|
|
3330
|
-
ch = source.charCodeAt(index);
|
|
3331
|
-
/* istanbul ignore else */
|
|
3332
|
-
if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
|
|
3333
|
-
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
3334
|
-
}
|
|
3335
|
-
}
|
|
3336
|
-
return {
|
|
3337
|
-
type: Token.NumericLiteral,
|
|
3338
|
-
value: parseInt(number, 2),
|
|
3339
|
-
lineNumber: lineNumber,
|
|
3340
|
-
lineStart: lineStart,
|
|
3341
|
-
range: [start, index]
|
|
3342
|
-
};
|
|
3402
|
+
return scanBinaryLiteral(start);
|
|
3343
3403
|
}
|
|
3344
3404
|
if (ch === 'o' || ch === 'O' || isOctalDigit(ch)) {
|
|
3345
3405
|
return scanOctalLiteral(ch, start);
|
|
@@ -3480,7 +3540,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3480
3540
|
}
|
|
3481
3541
|
} else {
|
|
3482
3542
|
++lineNumber;
|
|
3483
|
-
if (ch ===
|
|
3543
|
+
if (ch === '\r' && source[index] === '\n') {
|
|
3484
3544
|
++index;
|
|
3485
3545
|
}
|
|
3486
3546
|
lineStart = index;
|
|
@@ -3597,14 +3657,14 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3597
3657
|
}
|
|
3598
3658
|
} else {
|
|
3599
3659
|
++lineNumber;
|
|
3600
|
-
if (ch ===
|
|
3660
|
+
if (ch === '\r' && source[index] === '\n') {
|
|
3601
3661
|
++index;
|
|
3602
3662
|
}
|
|
3603
3663
|
lineStart = index;
|
|
3604
3664
|
}
|
|
3605
3665
|
} else if (isLineTerminator(ch.charCodeAt(0))) {
|
|
3606
3666
|
++lineNumber;
|
|
3607
|
-
if (ch ===
|
|
3667
|
+
if (ch === '\r' && source[index] === '\n') {
|
|
3608
3668
|
++index;
|
|
3609
3669
|
}
|
|
3610
3670
|
lineStart = index;
|
|
@@ -3651,39 +3711,77 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3651
3711
|
return template;
|
|
3652
3712
|
}
|
|
3653
3713
|
|
|
3654
|
-
function
|
|
3655
|
-
var
|
|
3714
|
+
function testRegExp(pattern, flags) {
|
|
3715
|
+
var tmp = pattern,
|
|
3716
|
+
value;
|
|
3656
3717
|
|
|
3657
|
-
|
|
3658
|
-
|
|
3718
|
+
if (flags.indexOf('u') >= 0) {
|
|
3719
|
+
// Replace each astral symbol and every Unicode code point
|
|
3720
|
+
// escape sequence with a single ASCII symbol to avoid throwing on
|
|
3721
|
+
// regular expressions that are only valid in combination with the
|
|
3722
|
+
// `/u` flag.
|
|
3723
|
+
// Note: replacing with the ASCII symbol `x` might cause false
|
|
3724
|
+
// negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
|
|
3725
|
+
// perfectly valid pattern that is equivalent to `[a-b]`, but it
|
|
3726
|
+
// would be replaced by `[x-b]` which throws an error.
|
|
3727
|
+
tmp = tmp
|
|
3728
|
+
.replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) {
|
|
3729
|
+
if (parseInt($1, 16) <= 0x10FFFF) {
|
|
3730
|
+
return 'x';
|
|
3731
|
+
}
|
|
3732
|
+
throwError({}, Messages.InvalidRegExp);
|
|
3733
|
+
})
|
|
3734
|
+
.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
|
|
3735
|
+
}
|
|
3736
|
+
|
|
3737
|
+
// First, detect invalid regular expressions.
|
|
3738
|
+
try {
|
|
3739
|
+
value = new RegExp(tmp);
|
|
3740
|
+
} catch (e) {
|
|
3741
|
+
throwError({}, Messages.InvalidRegExp);
|
|
3742
|
+
}
|
|
3743
|
+
|
|
3744
|
+
// Return a regular expression object for this pattern-flag pair, or
|
|
3745
|
+
// `null` in case the current environment doesn't support the flags it
|
|
3746
|
+
// uses.
|
|
3747
|
+
try {
|
|
3748
|
+
return new RegExp(pattern, flags);
|
|
3749
|
+
} catch (exception) {
|
|
3750
|
+
return null;
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
|
|
3754
|
+
function scanRegExpBody() {
|
|
3755
|
+
var ch, str, classMarker, terminated, body;
|
|
3659
3756
|
|
|
3660
|
-
start = index;
|
|
3661
3757
|
ch = source[index];
|
|
3662
3758
|
assert(ch === '/', 'Regular expression literal must start with a slash');
|
|
3663
3759
|
str = source[index++];
|
|
3664
3760
|
|
|
3761
|
+
classMarker = false;
|
|
3762
|
+
terminated = false;
|
|
3665
3763
|
while (index < length) {
|
|
3666
3764
|
ch = source[index++];
|
|
3667
3765
|
str += ch;
|
|
3668
|
-
if (
|
|
3766
|
+
if (ch === '\\') {
|
|
3767
|
+
ch = source[index++];
|
|
3768
|
+
// ECMA-262 7.8.5
|
|
3769
|
+
if (isLineTerminator(ch.charCodeAt(0))) {
|
|
3770
|
+
throwError({}, Messages.UnterminatedRegExp);
|
|
3771
|
+
}
|
|
3772
|
+
str += ch;
|
|
3773
|
+
} else if (isLineTerminator(ch.charCodeAt(0))) {
|
|
3774
|
+
throwError({}, Messages.UnterminatedRegExp);
|
|
3775
|
+
} else if (classMarker) {
|
|
3669
3776
|
if (ch === ']') {
|
|
3670
3777
|
classMarker = false;
|
|
3671
3778
|
}
|
|
3672
3779
|
} else {
|
|
3673
|
-
if (ch === '
|
|
3674
|
-
ch = source[index++];
|
|
3675
|
-
// ECMA-262 7.8.5
|
|
3676
|
-
if (isLineTerminator(ch.charCodeAt(0))) {
|
|
3677
|
-
throwError({}, Messages.UnterminatedRegExp);
|
|
3678
|
-
}
|
|
3679
|
-
str += ch;
|
|
3680
|
-
} else if (ch === '/') {
|
|
3780
|
+
if (ch === '/') {
|
|
3681
3781
|
terminated = true;
|
|
3682
3782
|
break;
|
|
3683
3783
|
} else if (ch === '[') {
|
|
3684
3784
|
classMarker = true;
|
|
3685
|
-
} else if (isLineTerminator(ch.charCodeAt(0))) {
|
|
3686
|
-
throwError({}, Messages.UnterminatedRegExp);
|
|
3687
3785
|
}
|
|
3688
3786
|
}
|
|
3689
3787
|
}
|
|
@@ -3693,8 +3791,17 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3693
3791
|
}
|
|
3694
3792
|
|
|
3695
3793
|
// Exclude leading and trailing slash.
|
|
3696
|
-
|
|
3794
|
+
body = str.substr(1, str.length - 2);
|
|
3795
|
+
return {
|
|
3796
|
+
value: body,
|
|
3797
|
+
literal: str
|
|
3798
|
+
};
|
|
3799
|
+
}
|
|
3697
3800
|
|
|
3801
|
+
function scanRegExpFlags() {
|
|
3802
|
+
var ch, str, flags, restore;
|
|
3803
|
+
|
|
3804
|
+
str = '';
|
|
3698
3805
|
flags = '';
|
|
3699
3806
|
while (index < length) {
|
|
3700
3807
|
ch = source[index];
|
|
@@ -3709,7 +3816,6 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3709
3816
|
++index;
|
|
3710
3817
|
restore = index;
|
|
3711
3818
|
ch = scanHexEscape('u');
|
|
3712
|
-
/* istanbul ignore else */
|
|
3713
3819
|
if (ch) {
|
|
3714
3820
|
flags += ch;
|
|
3715
3821
|
for (str += '\\u'; restore < index; ++restore) {
|
|
@@ -3723,6 +3829,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3723
3829
|
throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
3724
3830
|
} else {
|
|
3725
3831
|
str += '\\';
|
|
3832
|
+
throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
3726
3833
|
}
|
|
3727
3834
|
} else {
|
|
3728
3835
|
flags += ch;
|
|
@@ -3730,61 +3837,43 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3730
3837
|
}
|
|
3731
3838
|
}
|
|
3732
3839
|
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
// `/u` flag.
|
|
3739
|
-
// Note: replacing with the ASCII symbol `x` might cause false
|
|
3740
|
-
// negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
|
|
3741
|
-
// perfectly valid pattern that is equivalent to `[a-b]`, but it
|
|
3742
|
-
// would be replaced by `[x-b]` which throws an error.
|
|
3743
|
-
tmp = tmp
|
|
3744
|
-
.replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) {
|
|
3745
|
-
if (parseInt($1, 16) <= 0x10FFFF) {
|
|
3746
|
-
return 'x';
|
|
3747
|
-
}
|
|
3748
|
-
throwError({}, Messages.InvalidRegExp);
|
|
3749
|
-
})
|
|
3750
|
-
.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
|
|
3751
|
-
}
|
|
3840
|
+
return {
|
|
3841
|
+
value: flags,
|
|
3842
|
+
literal: str
|
|
3843
|
+
};
|
|
3844
|
+
}
|
|
3752
3845
|
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
value = new RegExp(tmp);
|
|
3756
|
-
} catch (e) {
|
|
3757
|
-
throwError({}, Messages.InvalidRegExp);
|
|
3758
|
-
}
|
|
3846
|
+
function scanRegExp() {
|
|
3847
|
+
var start, body, flags, value;
|
|
3759
3848
|
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
}
|
|
3849
|
+
lookahead = null;
|
|
3850
|
+
skipComment();
|
|
3851
|
+
start = index;
|
|
3852
|
+
|
|
3853
|
+
body = scanRegExpBody();
|
|
3854
|
+
flags = scanRegExpFlags();
|
|
3855
|
+
value = testRegExp(body.value, flags.value);
|
|
3768
3856
|
|
|
3769
3857
|
if (extra.tokenize) {
|
|
3770
3858
|
return {
|
|
3771
3859
|
type: Token.RegularExpression,
|
|
3772
3860
|
value: value,
|
|
3773
3861
|
regex: {
|
|
3774
|
-
pattern:
|
|
3775
|
-
flags: flags
|
|
3862
|
+
pattern: body.value,
|
|
3863
|
+
flags: flags.value
|
|
3776
3864
|
},
|
|
3777
3865
|
lineNumber: lineNumber,
|
|
3778
3866
|
lineStart: lineStart,
|
|
3779
3867
|
range: [start, index]
|
|
3780
3868
|
};
|
|
3781
3869
|
}
|
|
3870
|
+
|
|
3782
3871
|
return {
|
|
3783
|
-
literal:
|
|
3872
|
+
literal: body.literal + flags.literal,
|
|
3784
3873
|
value: value,
|
|
3785
3874
|
regex: {
|
|
3786
|
-
pattern:
|
|
3787
|
-
flags: flags
|
|
3875
|
+
pattern: body.value,
|
|
3876
|
+
flags: flags.value
|
|
3788
3877
|
},
|
|
3789
3878
|
range: [start, index]
|
|
3790
3879
|
};
|
|
@@ -3851,7 +3940,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3851
3940
|
}
|
|
3852
3941
|
return scanRegExp();
|
|
3853
3942
|
}
|
|
3854
|
-
if (prevToken.type === 'Keyword') {
|
|
3943
|
+
if (prevToken.type === 'Keyword' && prevToken.value !== 'this') {
|
|
3855
3944
|
return scanRegExp();
|
|
3856
3945
|
}
|
|
3857
3946
|
return scanPunctuator();
|
|
@@ -3860,7 +3949,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3860
3949
|
function advance() {
|
|
3861
3950
|
var ch;
|
|
3862
3951
|
|
|
3863
|
-
if (!state.
|
|
3952
|
+
if (!state.inJSXChild) {
|
|
3864
3953
|
skipComment();
|
|
3865
3954
|
}
|
|
3866
3955
|
|
|
@@ -3873,8 +3962,8 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3873
3962
|
};
|
|
3874
3963
|
}
|
|
3875
3964
|
|
|
3876
|
-
if (state.
|
|
3877
|
-
return
|
|
3965
|
+
if (state.inJSXChild) {
|
|
3966
|
+
return advanceJSXChild();
|
|
3878
3967
|
}
|
|
3879
3968
|
|
|
3880
3969
|
ch = source.charCodeAt(index);
|
|
@@ -3886,14 +3975,14 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
3886
3975
|
|
|
3887
3976
|
// String literal starts with single quote (#39) or double quote (#34).
|
|
3888
3977
|
if (ch === 39 || ch === 34) {
|
|
3889
|
-
if (state.
|
|
3890
|
-
return
|
|
3978
|
+
if (state.inJSXTag) {
|
|
3979
|
+
return scanJSXStringLiteral();
|
|
3891
3980
|
}
|
|
3892
3981
|
return scanStringLiteral();
|
|
3893
3982
|
}
|
|
3894
3983
|
|
|
3895
|
-
if (state.
|
|
3896
|
-
return
|
|
3984
|
+
if (state.inJSXTag && isJSXIdentifierStart(ch)) {
|
|
3985
|
+
return scanJSXIdentifier();
|
|
3897
3986
|
}
|
|
3898
3987
|
|
|
3899
3988
|
if (ch === 96) {
|
|
@@ -4504,78 +4593,78 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
4504
4593
|
};
|
|
4505
4594
|
},
|
|
4506
4595
|
|
|
4507
|
-
|
|
4596
|
+
createJSXAttribute: function (name, value) {
|
|
4508
4597
|
return {
|
|
4509
|
-
type: Syntax.
|
|
4598
|
+
type: Syntax.JSXAttribute,
|
|
4510
4599
|
name: name,
|
|
4511
4600
|
value: value || null
|
|
4512
4601
|
};
|
|
4513
4602
|
},
|
|
4514
4603
|
|
|
4515
|
-
|
|
4604
|
+
createJSXSpreadAttribute: function (argument) {
|
|
4516
4605
|
return {
|
|
4517
|
-
type: Syntax.
|
|
4606
|
+
type: Syntax.JSXSpreadAttribute,
|
|
4518
4607
|
argument: argument
|
|
4519
4608
|
};
|
|
4520
4609
|
},
|
|
4521
4610
|
|
|
4522
|
-
|
|
4611
|
+
createJSXIdentifier: function (name) {
|
|
4523
4612
|
return {
|
|
4524
|
-
type: Syntax.
|
|
4613
|
+
type: Syntax.JSXIdentifier,
|
|
4525
4614
|
name: name
|
|
4526
4615
|
};
|
|
4527
4616
|
},
|
|
4528
4617
|
|
|
4529
|
-
|
|
4618
|
+
createJSXNamespacedName: function (namespace, name) {
|
|
4530
4619
|
return {
|
|
4531
|
-
type: Syntax.
|
|
4620
|
+
type: Syntax.JSXNamespacedName,
|
|
4532
4621
|
namespace: namespace,
|
|
4533
4622
|
name: name
|
|
4534
4623
|
};
|
|
4535
4624
|
},
|
|
4536
4625
|
|
|
4537
|
-
|
|
4626
|
+
createJSXMemberExpression: function (object, property) {
|
|
4538
4627
|
return {
|
|
4539
|
-
type: Syntax.
|
|
4628
|
+
type: Syntax.JSXMemberExpression,
|
|
4540
4629
|
object: object,
|
|
4541
4630
|
property: property
|
|
4542
4631
|
};
|
|
4543
4632
|
},
|
|
4544
4633
|
|
|
4545
|
-
|
|
4634
|
+
createJSXElement: function (openingElement, closingElement, children) {
|
|
4546
4635
|
return {
|
|
4547
|
-
type: Syntax.
|
|
4636
|
+
type: Syntax.JSXElement,
|
|
4548
4637
|
openingElement: openingElement,
|
|
4549
4638
|
closingElement: closingElement,
|
|
4550
4639
|
children: children
|
|
4551
4640
|
};
|
|
4552
4641
|
},
|
|
4553
4642
|
|
|
4554
|
-
|
|
4643
|
+
createJSXEmptyExpression: function () {
|
|
4555
4644
|
return {
|
|
4556
|
-
type: Syntax.
|
|
4645
|
+
type: Syntax.JSXEmptyExpression
|
|
4557
4646
|
};
|
|
4558
4647
|
},
|
|
4559
4648
|
|
|
4560
|
-
|
|
4649
|
+
createJSXExpressionContainer: function (expression) {
|
|
4561
4650
|
return {
|
|
4562
|
-
type: Syntax.
|
|
4651
|
+
type: Syntax.JSXExpressionContainer,
|
|
4563
4652
|
expression: expression
|
|
4564
4653
|
};
|
|
4565
4654
|
},
|
|
4566
4655
|
|
|
4567
|
-
|
|
4656
|
+
createJSXOpeningElement: function (name, attributes, selfClosing) {
|
|
4568
4657
|
return {
|
|
4569
|
-
type: Syntax.
|
|
4658
|
+
type: Syntax.JSXOpeningElement,
|
|
4570
4659
|
name: name,
|
|
4571
4660
|
selfClosing: selfClosing,
|
|
4572
4661
|
attributes: attributes
|
|
4573
4662
|
};
|
|
4574
4663
|
},
|
|
4575
4664
|
|
|
4576
|
-
|
|
4665
|
+
createJSXClosingElement: function (name) {
|
|
4577
4666
|
return {
|
|
4578
|
-
type: Syntax.
|
|
4667
|
+
type: Syntax.JSXClosingElement,
|
|
4579
4668
|
name: name
|
|
4580
4669
|
};
|
|
4581
4670
|
},
|
|
@@ -4916,13 +5005,13 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
4916
5005
|
};
|
|
4917
5006
|
},
|
|
4918
5007
|
|
|
4919
|
-
createExportDeclaration: function (isDefault, declaration, specifiers,
|
|
5008
|
+
createExportDeclaration: function (isDefault, declaration, specifiers, src) {
|
|
4920
5009
|
return {
|
|
4921
5010
|
type: Syntax.ExportDeclaration,
|
|
4922
5011
|
'default': !!isDefault,
|
|
4923
5012
|
declaration: declaration,
|
|
4924
5013
|
specifiers: specifiers,
|
|
4925
|
-
source:
|
|
5014
|
+
source: src
|
|
4926
5015
|
};
|
|
4927
5016
|
},
|
|
4928
5017
|
|
|
@@ -4934,20 +5023,20 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
4934
5023
|
};
|
|
4935
5024
|
},
|
|
4936
5025
|
|
|
4937
|
-
createImportDeclaration: function (specifiers,
|
|
5026
|
+
createImportDeclaration: function (specifiers, src, isType) {
|
|
4938
5027
|
return {
|
|
4939
5028
|
type: Syntax.ImportDeclaration,
|
|
4940
5029
|
specifiers: specifiers,
|
|
4941
|
-
source:
|
|
5030
|
+
source: src,
|
|
4942
5031
|
isType: isType
|
|
4943
5032
|
};
|
|
4944
5033
|
},
|
|
4945
5034
|
|
|
4946
|
-
createYieldExpression: function (argument,
|
|
5035
|
+
createYieldExpression: function (argument, dlg) {
|
|
4947
5036
|
return {
|
|
4948
5037
|
type: Syntax.YieldExpression,
|
|
4949
5038
|
argument: argument,
|
|
4950
|
-
delegate:
|
|
5039
|
+
delegate: dlg
|
|
4951
5040
|
};
|
|
4952
5041
|
},
|
|
4953
5042
|
|
|
@@ -4993,9 +5082,9 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
4993
5082
|
args = Array.prototype.slice.call(arguments, 2),
|
|
4994
5083
|
msg = messageFormat.replace(
|
|
4995
5084
|
/%(\d)/g,
|
|
4996
|
-
function (whole,
|
|
4997
|
-
assert(
|
|
4998
|
-
return args[
|
|
5085
|
+
function (whole, idx) {
|
|
5086
|
+
assert(idx < args.length, 'Message reference must be in range');
|
|
5087
|
+
return args[idx];
|
|
4999
5088
|
}
|
|
5000
5089
|
);
|
|
5001
5090
|
|
|
@@ -5039,7 +5128,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
5039
5128
|
throwError(token, Messages.UnexpectedNumber);
|
|
5040
5129
|
}
|
|
5041
5130
|
|
|
5042
|
-
if (token.type === Token.StringLiteral || token.type === Token.
|
|
5131
|
+
if (token.type === Token.StringLiteral || token.type === Token.JSXText) {
|
|
5043
5132
|
throwError(token, Messages.UnexpectedString);
|
|
5044
5133
|
}
|
|
5045
5134
|
|
|
@@ -5202,7 +5291,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
5202
5291
|
// 11.1.4 Array Initialiser
|
|
5203
5292
|
|
|
5204
5293
|
function parseArrayInitialiser() {
|
|
5205
|
-
var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true,
|
|
5294
|
+
var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true,
|
|
5206
5295
|
marker = markerCreate();
|
|
5207
5296
|
|
|
5208
5297
|
expect('[');
|
|
@@ -5358,7 +5447,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
5358
5447
|
}
|
|
5359
5448
|
|
|
5360
5449
|
function parseObjectProperty() {
|
|
5361
|
-
var token, key, id,
|
|
5450
|
+
var token, key, id, param, computed,
|
|
5362
5451
|
marker = markerCreate(), returnType, typeParameters;
|
|
5363
5452
|
|
|
5364
5453
|
token = lookahead;
|
|
@@ -5764,7 +5853,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
5764
5853
|
}
|
|
5765
5854
|
|
|
5766
5855
|
if (match('<')) {
|
|
5767
|
-
return
|
|
5856
|
+
return parseJSXElement();
|
|
5768
5857
|
}
|
|
5769
5858
|
|
|
5770
5859
|
throwUnexpected(lex());
|
|
@@ -6412,9 +6501,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
6412
6501
|
// 11.14 Comma Operator
|
|
6413
6502
|
|
|
6414
6503
|
function parseExpression() {
|
|
6415
|
-
var marker, expr, expressions, sequence,
|
|
6416
|
-
|
|
6417
|
-
oldParenthesizedCount = state.parenthesizedCount;
|
|
6504
|
+
var marker, expr, expressions, sequence, spreadFound;
|
|
6418
6505
|
|
|
6419
6506
|
marker = markerCreate();
|
|
6420
6507
|
expr = parseAssignmentExpression();
|
|
@@ -6592,7 +6679,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
6592
6679
|
|
|
6593
6680
|
function parseObjectType(allowStatic) {
|
|
6594
6681
|
var callProperties = [], indexers = [], marker, optional = false,
|
|
6595
|
-
properties = [],
|
|
6682
|
+
properties = [], propertyKey, propertyTypeAnnotation,
|
|
6596
6683
|
token, isStatic, matchStatic;
|
|
6597
6684
|
|
|
6598
6685
|
expect('{');
|
|
@@ -6656,9 +6743,8 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
6656
6743
|
}
|
|
6657
6744
|
|
|
6658
6745
|
function parseGenericType() {
|
|
6659
|
-
var marker = markerCreate(),
|
|
6660
|
-
typeParameters = null, typeIdentifier
|
|
6661
|
-
typeIdentifierMarker = markerCreate;
|
|
6746
|
+
var marker = markerCreate(),
|
|
6747
|
+
typeParameters = null, typeIdentifier;
|
|
6662
6748
|
|
|
6663
6749
|
typeIdentifier = parseVariableIdentifier();
|
|
6664
6750
|
|
|
@@ -6748,7 +6834,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
6748
6834
|
// primary types are kind of like primary expressions...they're the
|
|
6749
6835
|
// primitives with which other types are constructed.
|
|
6750
6836
|
function parsePrimaryType() {
|
|
6751
|
-
var
|
|
6837
|
+
var params = null, returnType = null,
|
|
6752
6838
|
marker = markerCreate(), rest = null, tmp,
|
|
6753
6839
|
typeParameters, token, type, isGroupedType = false;
|
|
6754
6840
|
|
|
@@ -6994,7 +7080,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
6994
7080
|
|
|
6995
7081
|
if (kind === 'const') {
|
|
6996
7082
|
if (!match('=')) {
|
|
6997
|
-
throwError({}, Messages.
|
|
7083
|
+
throwError({}, Messages.NoUninitializedConst);
|
|
6998
7084
|
}
|
|
6999
7085
|
expect('=');
|
|
7000
7086
|
init = parseAssignmentExpression();
|
|
@@ -7086,7 +7172,8 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
7086
7172
|
}
|
|
7087
7173
|
|
|
7088
7174
|
function parseExportDeclaration() {
|
|
7089
|
-
var
|
|
7175
|
+
var declaration = null,
|
|
7176
|
+
possibleIdentifierToken, sourceElement,
|
|
7090
7177
|
isExportFromIdentifier,
|
|
7091
7178
|
src = null, specifiers = [],
|
|
7092
7179
|
marker = markerCreate();
|
|
@@ -7098,20 +7185,17 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
7098
7185
|
// export default ...
|
|
7099
7186
|
lex();
|
|
7100
7187
|
if (matchKeyword('function') || matchKeyword('class')) {
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
if (isIdentifierName(lookahead)) {
|
|
7188
|
+
possibleIdentifierToken = lookahead2();
|
|
7189
|
+
if (isIdentifierName(possibleIdentifierToken)) {
|
|
7104
7190
|
// covers:
|
|
7105
7191
|
// export default function foo () {}
|
|
7106
7192
|
// export default class foo {}
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
return markerApply(marker, delegate.createExportDeclaration(true, parseSourceElement(), [id], null));
|
|
7193
|
+
sourceElement = parseSourceElement();
|
|
7194
|
+
return markerApply(marker, delegate.createExportDeclaration(true, sourceElement, [sourceElement.id], null));
|
|
7110
7195
|
}
|
|
7111
7196
|
// covers:
|
|
7112
7197
|
// export default function () {}
|
|
7113
7198
|
// export default class {}
|
|
7114
|
-
rewind(backtrackToken);
|
|
7115
7199
|
switch (lookahead.value) {
|
|
7116
7200
|
case 'class':
|
|
7117
7201
|
return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null));
|
|
@@ -7869,7 +7953,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
7869
7953
|
|
|
7870
7954
|
state.labelSet.set(expr.name, true);
|
|
7871
7955
|
labeledBody = parseStatement();
|
|
7872
|
-
state.labelSet[
|
|
7956
|
+
state.labelSet["delete"](expr.name);
|
|
7873
7957
|
return markerApply(marker, delegate.createLabeledStatement(expr, labeledBody));
|
|
7874
7958
|
}
|
|
7875
7959
|
|
|
@@ -8270,55 +8354,25 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
8270
8354
|
return markerApply(marker, delegate.createAwaitExpression(expr));
|
|
8271
8355
|
}
|
|
8272
8356
|
|
|
8273
|
-
// 14
|
|
8357
|
+
// 14 Functions and classes
|
|
8274
8358
|
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
name = getFieldName(key);
|
|
8279
|
-
|
|
8280
|
-
if (propMap.has(name)) {
|
|
8281
|
-
propInfo = propMap.get(name);
|
|
8282
|
-
if (accessor === 'data') {
|
|
8283
|
-
isValidDuplicateProp = false;
|
|
8284
|
-
} else {
|
|
8285
|
-
if (accessor === 'get') {
|
|
8286
|
-
reversed = 'set';
|
|
8287
|
-
} else {
|
|
8288
|
-
reversed = 'get';
|
|
8289
|
-
}
|
|
8359
|
+
// 14.1 Functions is defined above (13 in ES5)
|
|
8360
|
+
// 14.2 Arrow Functions Definitions is defined in (7.3 assignments)
|
|
8290
8361
|
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
&& propInfo[reversed] !== undefined;
|
|
8298
|
-
}
|
|
8299
|
-
if (!isValidDuplicateProp) {
|
|
8300
|
-
throwError(key, Messages.IllegalDuplicateClassProperty);
|
|
8301
|
-
}
|
|
8302
|
-
} else {
|
|
8303
|
-
propInfo = {
|
|
8304
|
-
get: undefined,
|
|
8305
|
-
set: undefined,
|
|
8306
|
-
data: undefined
|
|
8307
|
-
};
|
|
8308
|
-
propMap.set(name, propInfo);
|
|
8309
|
-
}
|
|
8310
|
-
propInfo[accessor] = true;
|
|
8362
|
+
// 14.3 Method Definitions
|
|
8363
|
+
// 14.3.7
|
|
8364
|
+
function specialMethod(methodDefinition) {
|
|
8365
|
+
return methodDefinition.kind === 'get' ||
|
|
8366
|
+
methodDefinition.kind === 'set' ||
|
|
8367
|
+
methodDefinition.value.generator;
|
|
8311
8368
|
}
|
|
8312
8369
|
|
|
8313
|
-
function parseMethodDefinition(
|
|
8314
|
-
var token, param, propType,
|
|
8315
|
-
isAsync, typeParameters, tokenValue, returnType
|
|
8316
|
-
annotationMarker, propMap;
|
|
8370
|
+
function parseMethodDefinition(key, isStatic, generator, computed) {
|
|
8371
|
+
var token, param, propType,
|
|
8372
|
+
isAsync, typeParameters, tokenValue, returnType;
|
|
8317
8373
|
|
|
8318
8374
|
propType = isStatic ? ClassPropertyType["static"] : ClassPropertyType.prototype;
|
|
8319
8375
|
|
|
8320
|
-
propMap = existingPropNames[propType];
|
|
8321
|
-
|
|
8322
8376
|
if (generator) {
|
|
8323
8377
|
return delegate.createMethodDefinition(
|
|
8324
8378
|
propType,
|
|
@@ -8334,12 +8388,6 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
8334
8388
|
if (tokenValue === 'get' && !match('(')) {
|
|
8335
8389
|
key = parseObjectPropertyKey();
|
|
8336
8390
|
|
|
8337
|
-
// It is a syntax error if any other properties have a name
|
|
8338
|
-
// duplicating this one unless they are a setter
|
|
8339
|
-
if (!computed) {
|
|
8340
|
-
validateDuplicateProp(propMap, key, 'get');
|
|
8341
|
-
}
|
|
8342
|
-
|
|
8343
8391
|
expect('(');
|
|
8344
8392
|
expect(')');
|
|
8345
8393
|
if (match(':')) {
|
|
@@ -8356,12 +8404,6 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
8356
8404
|
if (tokenValue === 'set' && !match('(')) {
|
|
8357
8405
|
key = parseObjectPropertyKey();
|
|
8358
8406
|
|
|
8359
|
-
// It is a syntax error if any other properties have a name
|
|
8360
|
-
// duplicating this one unless they are a getter
|
|
8361
|
-
if (!computed) {
|
|
8362
|
-
validateDuplicateProp(propMap, key, 'set');
|
|
8363
|
-
}
|
|
8364
|
-
|
|
8365
8407
|
expect('(');
|
|
8366
8408
|
token = lookahead;
|
|
8367
8409
|
param = [ parseTypeAnnotatableIdentifier() ];
|
|
@@ -8392,12 +8434,6 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
8392
8434
|
key = parseObjectPropertyKey();
|
|
8393
8435
|
}
|
|
8394
8436
|
|
|
8395
|
-
// It is a syntax error if any other properties have the same name as a
|
|
8396
|
-
// non-getter, non-setter method
|
|
8397
|
-
if (!computed) {
|
|
8398
|
-
validateDuplicateProp(propMap, key, 'data');
|
|
8399
|
-
}
|
|
8400
|
-
|
|
8401
8437
|
return delegate.createMethodDefinition(
|
|
8402
8438
|
propType,
|
|
8403
8439
|
'',
|
|
@@ -8411,7 +8447,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
8411
8447
|
);
|
|
8412
8448
|
}
|
|
8413
8449
|
|
|
8414
|
-
function parseClassProperty(
|
|
8450
|
+
function parseClassProperty(key, computed, isStatic) {
|
|
8415
8451
|
var typeAnnotation;
|
|
8416
8452
|
|
|
8417
8453
|
typeAnnotation = parseTypeAnnotation();
|
|
@@ -8425,12 +8461,12 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
8425
8461
|
);
|
|
8426
8462
|
}
|
|
8427
8463
|
|
|
8428
|
-
function parseClassElement(
|
|
8464
|
+
function parseClassElement() {
|
|
8429
8465
|
var computed = false, generator = false, key, marker = markerCreate(),
|
|
8430
8466
|
isStatic = false, possiblyOpenBracketToken;
|
|
8431
8467
|
if (match(';')) {
|
|
8432
8468
|
lex();
|
|
8433
|
-
return;
|
|
8469
|
+
return undefined;
|
|
8434
8470
|
}
|
|
8435
8471
|
|
|
8436
8472
|
if (lookahead.value === 'static') {
|
|
@@ -8456,11 +8492,10 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
8456
8492
|
key = parseObjectPropertyKey();
|
|
8457
8493
|
|
|
8458
8494
|
if (!generator && lookahead.value === ':') {
|
|
8459
|
-
return markerApply(marker, parseClassProperty(
|
|
8495
|
+
return markerApply(marker, parseClassProperty(key, computed, isStatic));
|
|
8460
8496
|
}
|
|
8461
8497
|
|
|
8462
8498
|
return markerApply(marker, parseMethodDefinition(
|
|
8463
|
-
existingProps,
|
|
8464
8499
|
key,
|
|
8465
8500
|
isStatic,
|
|
8466
8501
|
generator,
|
|
@@ -8469,7 +8504,8 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
8469
8504
|
}
|
|
8470
8505
|
|
|
8471
8506
|
function parseClassBody() {
|
|
8472
|
-
var classElement, classElements = [], existingProps = {},
|
|
8507
|
+
var classElement, classElements = [], existingProps = {},
|
|
8508
|
+
marker = markerCreate(), propName, propType;
|
|
8473
8509
|
|
|
8474
8510
|
existingProps[ClassPropertyType["static"]] = new StringMap();
|
|
8475
8511
|
existingProps[ClassPropertyType.prototype] = new StringMap();
|
|
@@ -8484,6 +8520,25 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
8484
8520
|
|
|
8485
8521
|
if (typeof classElement !== 'undefined') {
|
|
8486
8522
|
classElements.push(classElement);
|
|
8523
|
+
|
|
8524
|
+
propName = !classElement.computed && getFieldName(classElement.key);
|
|
8525
|
+
if (propName !== false) {
|
|
8526
|
+
propType = classElement["static"] ?
|
|
8527
|
+
ClassPropertyType["static"] :
|
|
8528
|
+
ClassPropertyType.prototype;
|
|
8529
|
+
|
|
8530
|
+
if (classElement.type === Syntax.MethodDefinition) {
|
|
8531
|
+
if (propName === 'constructor' && !classElement["static"]) {
|
|
8532
|
+
if (specialMethod(classElement)) {
|
|
8533
|
+
throwError(classElement, Messages.IllegalClassConstructorProperty);
|
|
8534
|
+
}
|
|
8535
|
+
if (existingProps[ClassPropertyType.prototype].has('constructor')) {
|
|
8536
|
+
throwError(classElement.key, Messages.IllegalDuplicateClassProperty);
|
|
8537
|
+
}
|
|
8538
|
+
}
|
|
8539
|
+
existingProps[propType].set(propName, true);
|
|
8540
|
+
}
|
|
8541
|
+
}
|
|
8487
8542
|
}
|
|
8488
8543
|
}
|
|
8489
8544
|
|
|
@@ -8697,188 +8752,31 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
8697
8752
|
throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
|
|
8698
8753
|
}
|
|
8699
8754
|
} else {
|
|
8700
|
-
if (!firstRestricted && token.octal) {
|
|
8701
|
-
firstRestricted = token;
|
|
8702
|
-
}
|
|
8703
|
-
}
|
|
8704
|
-
}
|
|
8705
|
-
|
|
8706
|
-
while (index < length) {
|
|
8707
|
-
sourceElement = parseProgramElement();
|
|
8708
|
-
if (typeof sourceElement === 'undefined') {
|
|
8709
|
-
break;
|
|
8710
|
-
}
|
|
8711
|
-
sourceElements.push(sourceElement);
|
|
8712
|
-
}
|
|
8713
|
-
return sourceElements;
|
|
8714
|
-
}
|
|
8715
|
-
|
|
8716
|
-
function parseProgram() {
|
|
8717
|
-
var body, marker = markerCreate();
|
|
8718
|
-
strict = extra.sourceType === 'module';
|
|
8719
|
-
peek();
|
|
8720
|
-
body = parseProgramElements();
|
|
8721
|
-
return markerApply(marker, delegate.createProgram(body));
|
|
8722
|
-
}
|
|
8723
|
-
|
|
8724
|
-
// The following functions are needed only when the option to preserve
|
|
8725
|
-
// the comments is active.
|
|
8726
|
-
|
|
8727
|
-
function addComment(type, value, start, end, loc) {
|
|
8728
|
-
var comment;
|
|
8729
|
-
|
|
8730
|
-
assert(typeof start === 'number', 'Comment must have valid position');
|
|
8731
|
-
|
|
8732
|
-
// Because the way the actual token is scanned, often the comments
|
|
8733
|
-
// (if any) are skipped twice during the lexical analysis.
|
|
8734
|
-
// Thus, we need to skip adding a comment if the comment array already
|
|
8735
|
-
// handled it.
|
|
8736
|
-
if (state.lastCommentStart >= start) {
|
|
8737
|
-
return;
|
|
8738
|
-
}
|
|
8739
|
-
state.lastCommentStart = start;
|
|
8740
|
-
|
|
8741
|
-
comment = {
|
|
8742
|
-
type: type,
|
|
8743
|
-
value: value
|
|
8744
|
-
};
|
|
8745
|
-
if (extra.range) {
|
|
8746
|
-
comment.range = [start, end];
|
|
8747
|
-
}
|
|
8748
|
-
if (extra.loc) {
|
|
8749
|
-
comment.loc = loc;
|
|
8750
|
-
}
|
|
8751
|
-
extra.comments.push(comment);
|
|
8752
|
-
if (extra.attachComment) {
|
|
8753
|
-
extra.leadingComments.push(comment);
|
|
8754
|
-
extra.trailingComments.push(comment);
|
|
8755
|
-
}
|
|
8756
|
-
}
|
|
8757
|
-
|
|
8758
|
-
function scanComment() {
|
|
8759
|
-
var comment, ch, loc, start, blockComment, lineComment;
|
|
8760
|
-
|
|
8761
|
-
comment = '';
|
|
8762
|
-
blockComment = false;
|
|
8763
|
-
lineComment = false;
|
|
8764
|
-
|
|
8765
|
-
while (index < length) {
|
|
8766
|
-
ch = source[index];
|
|
8767
|
-
|
|
8768
|
-
if (lineComment) {
|
|
8769
|
-
ch = source[index++];
|
|
8770
|
-
if (isLineTerminator(ch.charCodeAt(0))) {
|
|
8771
|
-
loc.end = {
|
|
8772
|
-
line: lineNumber,
|
|
8773
|
-
column: index - lineStart - 1
|
|
8774
|
-
};
|
|
8775
|
-
lineComment = false;
|
|
8776
|
-
addComment('Line', comment, start, index - 1, loc);
|
|
8777
|
-
if (ch === '\r' && source[index] === '\n') {
|
|
8778
|
-
++index;
|
|
8779
|
-
}
|
|
8780
|
-
++lineNumber;
|
|
8781
|
-
lineStart = index;
|
|
8782
|
-
comment = '';
|
|
8783
|
-
} else if (index >= length) {
|
|
8784
|
-
lineComment = false;
|
|
8785
|
-
comment += ch;
|
|
8786
|
-
loc.end = {
|
|
8787
|
-
line: lineNumber,
|
|
8788
|
-
column: length - lineStart
|
|
8789
|
-
};
|
|
8790
|
-
addComment('Line', comment, start, length, loc);
|
|
8791
|
-
} else {
|
|
8792
|
-
comment += ch;
|
|
8793
|
-
}
|
|
8794
|
-
} else if (blockComment) {
|
|
8795
|
-
if (isLineTerminator(ch.charCodeAt(0))) {
|
|
8796
|
-
if (ch === '\r') {
|
|
8797
|
-
++index;
|
|
8798
|
-
comment += '\r';
|
|
8799
|
-
}
|
|
8800
|
-
if (ch !== '\r' || source[index] === '\n') {
|
|
8801
|
-
comment += source[index];
|
|
8802
|
-
++lineNumber;
|
|
8803
|
-
++index;
|
|
8804
|
-
lineStart = index;
|
|
8805
|
-
if (index >= length) {
|
|
8806
|
-
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
8807
|
-
}
|
|
8808
|
-
}
|
|
8809
|
-
} else {
|
|
8810
|
-
ch = source[index++];
|
|
8811
|
-
if (index >= length) {
|
|
8812
|
-
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
8813
|
-
}
|
|
8814
|
-
comment += ch;
|
|
8815
|
-
if (ch === '*') {
|
|
8816
|
-
ch = source[index];
|
|
8817
|
-
if (ch === '/') {
|
|
8818
|
-
comment = comment.substr(0, comment.length - 1);
|
|
8819
|
-
blockComment = false;
|
|
8820
|
-
++index;
|
|
8821
|
-
loc.end = {
|
|
8822
|
-
line: lineNumber,
|
|
8823
|
-
column: index - lineStart
|
|
8824
|
-
};
|
|
8825
|
-
addComment('Block', comment, start, index, loc);
|
|
8826
|
-
comment = '';
|
|
8827
|
-
}
|
|
8828
|
-
}
|
|
8829
|
-
}
|
|
8830
|
-
} else if (ch === '/') {
|
|
8831
|
-
ch = source[index + 1];
|
|
8832
|
-
if (ch === '/') {
|
|
8833
|
-
loc = {
|
|
8834
|
-
start: {
|
|
8835
|
-
line: lineNumber,
|
|
8836
|
-
column: index - lineStart
|
|
8837
|
-
}
|
|
8838
|
-
};
|
|
8839
|
-
start = index;
|
|
8840
|
-
index += 2;
|
|
8841
|
-
lineComment = true;
|
|
8842
|
-
if (index >= length) {
|
|
8843
|
-
loc.end = {
|
|
8844
|
-
line: lineNumber,
|
|
8845
|
-
column: index - lineStart
|
|
8846
|
-
};
|
|
8847
|
-
lineComment = false;
|
|
8848
|
-
addComment('Line', comment, start, index, loc);
|
|
8849
|
-
}
|
|
8850
|
-
} else if (ch === '*') {
|
|
8851
|
-
start = index;
|
|
8852
|
-
index += 2;
|
|
8853
|
-
blockComment = true;
|
|
8854
|
-
loc = {
|
|
8855
|
-
start: {
|
|
8856
|
-
line: lineNumber,
|
|
8857
|
-
column: index - lineStart - 2
|
|
8858
|
-
}
|
|
8859
|
-
};
|
|
8860
|
-
if (index >= length) {
|
|
8861
|
-
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
8862
|
-
}
|
|
8863
|
-
} else {
|
|
8864
|
-
break;
|
|
8865
|
-
}
|
|
8866
|
-
} else if (isWhiteSpace(ch.charCodeAt(0))) {
|
|
8867
|
-
++index;
|
|
8868
|
-
} else if (isLineTerminator(ch.charCodeAt(0))) {
|
|
8869
|
-
++index;
|
|
8870
|
-
if (ch === '\r' && source[index] === '\n') {
|
|
8871
|
-
++index;
|
|
8872
|
-
}
|
|
8873
|
-
++lineNumber;
|
|
8874
|
-
lineStart = index;
|
|
8875
|
-
} else {
|
|
8755
|
+
if (!firstRestricted && token.octal) {
|
|
8756
|
+
firstRestricted = token;
|
|
8757
|
+
}
|
|
8758
|
+
}
|
|
8759
|
+
}
|
|
8760
|
+
|
|
8761
|
+
while (index < length) {
|
|
8762
|
+
sourceElement = parseProgramElement();
|
|
8763
|
+
if (typeof sourceElement === 'undefined') {
|
|
8876
8764
|
break;
|
|
8877
8765
|
}
|
|
8766
|
+
sourceElements.push(sourceElement);
|
|
8878
8767
|
}
|
|
8768
|
+
return sourceElements;
|
|
8769
|
+
}
|
|
8770
|
+
|
|
8771
|
+
function parseProgram() {
|
|
8772
|
+
var body, marker = markerCreate();
|
|
8773
|
+
strict = extra.sourceType === 'module';
|
|
8774
|
+
peek();
|
|
8775
|
+
body = parseProgramElements();
|
|
8776
|
+
return markerApply(marker, delegate.createProgram(body));
|
|
8879
8777
|
}
|
|
8880
8778
|
|
|
8881
|
-
// 16
|
|
8779
|
+
// 16 JSX
|
|
8882
8780
|
|
|
8883
8781
|
XHTMLEntities = {
|
|
8884
8782
|
quot: '\u0022',
|
|
@@ -9136,48 +9034,48 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
9136
9034
|
diams: '\u2666'
|
|
9137
9035
|
};
|
|
9138
9036
|
|
|
9139
|
-
function
|
|
9140
|
-
if (object.type === Syntax.
|
|
9037
|
+
function getQualifiedJSXName(object) {
|
|
9038
|
+
if (object.type === Syntax.JSXIdentifier) {
|
|
9141
9039
|
return object.name;
|
|
9142
9040
|
}
|
|
9143
|
-
if (object.type === Syntax.
|
|
9041
|
+
if (object.type === Syntax.JSXNamespacedName) {
|
|
9144
9042
|
return object.namespace.name + ':' + object.name.name;
|
|
9145
9043
|
}
|
|
9146
9044
|
/* istanbul ignore else */
|
|
9147
|
-
if (object.type === Syntax.
|
|
9045
|
+
if (object.type === Syntax.JSXMemberExpression) {
|
|
9148
9046
|
return (
|
|
9149
|
-
|
|
9150
|
-
|
|
9047
|
+
getQualifiedJSXName(object.object) + '.' +
|
|
9048
|
+
getQualifiedJSXName(object.property)
|
|
9151
9049
|
);
|
|
9152
9050
|
}
|
|
9153
9051
|
/* istanbul ignore next */
|
|
9154
9052
|
throwUnexpected(object);
|
|
9155
9053
|
}
|
|
9156
9054
|
|
|
9157
|
-
function
|
|
9055
|
+
function isJSXIdentifierStart(ch) {
|
|
9158
9056
|
// exclude backslash (\)
|
|
9159
9057
|
return (ch !== 92) && isIdentifierStart(ch);
|
|
9160
9058
|
}
|
|
9161
9059
|
|
|
9162
|
-
function
|
|
9060
|
+
function isJSXIdentifierPart(ch) {
|
|
9163
9061
|
// exclude backslash (\) and add hyphen (-)
|
|
9164
9062
|
return (ch !== 92) && (ch === 45 || isIdentifierPart(ch));
|
|
9165
9063
|
}
|
|
9166
9064
|
|
|
9167
|
-
function
|
|
9065
|
+
function scanJSXIdentifier() {
|
|
9168
9066
|
var ch, start, value = '';
|
|
9169
9067
|
|
|
9170
9068
|
start = index;
|
|
9171
9069
|
while (index < length) {
|
|
9172
9070
|
ch = source.charCodeAt(index);
|
|
9173
|
-
if (!
|
|
9071
|
+
if (!isJSXIdentifierPart(ch)) {
|
|
9174
9072
|
break;
|
|
9175
9073
|
}
|
|
9176
9074
|
value += source[index++];
|
|
9177
9075
|
}
|
|
9178
9076
|
|
|
9179
9077
|
return {
|
|
9180
|
-
type: Token.
|
|
9078
|
+
type: Token.JSXIdentifier,
|
|
9181
9079
|
value: value,
|
|
9182
9080
|
lineNumber: lineNumber,
|
|
9183
9081
|
lineStart: lineStart,
|
|
@@ -9185,7 +9083,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
9185
9083
|
};
|
|
9186
9084
|
}
|
|
9187
9085
|
|
|
9188
|
-
function
|
|
9086
|
+
function scanJSXEntity() {
|
|
9189
9087
|
var ch, str = '', start = index, count = 0, code;
|
|
9190
9088
|
ch = source[index];
|
|
9191
9089
|
assert(ch === '&', 'Entity must start with an ampersand');
|
|
@@ -9223,7 +9121,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
9223
9121
|
return '&';
|
|
9224
9122
|
}
|
|
9225
9123
|
|
|
9226
|
-
function
|
|
9124
|
+
function scanJSXText(stopChars) {
|
|
9227
9125
|
var ch, str = '', start;
|
|
9228
9126
|
start = index;
|
|
9229
9127
|
while (index < length) {
|
|
@@ -9232,7 +9130,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
9232
9130
|
break;
|
|
9233
9131
|
}
|
|
9234
9132
|
if (ch === '&') {
|
|
9235
|
-
str +=
|
|
9133
|
+
str += scanJSXEntity();
|
|
9236
9134
|
} else {
|
|
9237
9135
|
index++;
|
|
9238
9136
|
if (ch === '\r' && source[index] === '\n') {
|
|
@@ -9248,7 +9146,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
9248
9146
|
}
|
|
9249
9147
|
}
|
|
9250
9148
|
return {
|
|
9251
|
-
type: Token.
|
|
9149
|
+
type: Token.JSXText,
|
|
9252
9150
|
value: str,
|
|
9253
9151
|
lineNumber: lineNumber,
|
|
9254
9152
|
lineStart: lineStart,
|
|
@@ -9256,7 +9154,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
9256
9154
|
};
|
|
9257
9155
|
}
|
|
9258
9156
|
|
|
9259
|
-
function
|
|
9157
|
+
function scanJSXStringLiteral() {
|
|
9260
9158
|
var innerToken, quote, start;
|
|
9261
9159
|
|
|
9262
9160
|
quote = source[index];
|
|
@@ -9266,7 +9164,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
9266
9164
|
start = index;
|
|
9267
9165
|
++index;
|
|
9268
9166
|
|
|
9269
|
-
innerToken =
|
|
9167
|
+
innerToken = scanJSXText([quote]);
|
|
9270
9168
|
|
|
9271
9169
|
if (quote !== source[index]) {
|
|
9272
9170
|
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
|
|
@@ -9280,256 +9178,256 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
9280
9178
|
}
|
|
9281
9179
|
|
|
9282
9180
|
/**
|
|
9283
|
-
* Between
|
|
9284
|
-
* is not another
|
|
9181
|
+
* Between JSX opening and closing tags (e.g. <foo>HERE</foo>), anything that
|
|
9182
|
+
* is not another JSX tag and is not an expression wrapped by {} is text.
|
|
9285
9183
|
*/
|
|
9286
|
-
function
|
|
9184
|
+
function advanceJSXChild() {
|
|
9287
9185
|
var ch = source.charCodeAt(index);
|
|
9288
9186
|
|
|
9289
9187
|
// '<' 60, '>' 62, '{' 123, '}' 125
|
|
9290
9188
|
if (ch !== 60 && ch !== 62 && ch !== 123 && ch !== 125) {
|
|
9291
|
-
return
|
|
9189
|
+
return scanJSXText(['<', '>', '{', '}']);
|
|
9292
9190
|
}
|
|
9293
9191
|
|
|
9294
9192
|
return scanPunctuator();
|
|
9295
9193
|
}
|
|
9296
9194
|
|
|
9297
|
-
function
|
|
9195
|
+
function parseJSXIdentifier() {
|
|
9298
9196
|
var token, marker = markerCreate();
|
|
9299
9197
|
|
|
9300
|
-
if (lookahead.type !== Token.
|
|
9198
|
+
if (lookahead.type !== Token.JSXIdentifier) {
|
|
9301
9199
|
throwUnexpected(lookahead);
|
|
9302
9200
|
}
|
|
9303
9201
|
|
|
9304
9202
|
token = lex();
|
|
9305
|
-
return markerApply(marker, delegate.
|
|
9203
|
+
return markerApply(marker, delegate.createJSXIdentifier(token.value));
|
|
9306
9204
|
}
|
|
9307
9205
|
|
|
9308
|
-
function
|
|
9206
|
+
function parseJSXNamespacedName() {
|
|
9309
9207
|
var namespace, name, marker = markerCreate();
|
|
9310
9208
|
|
|
9311
|
-
namespace =
|
|
9209
|
+
namespace = parseJSXIdentifier();
|
|
9312
9210
|
expect(':');
|
|
9313
|
-
name =
|
|
9211
|
+
name = parseJSXIdentifier();
|
|
9314
9212
|
|
|
9315
|
-
return markerApply(marker, delegate.
|
|
9213
|
+
return markerApply(marker, delegate.createJSXNamespacedName(namespace, name));
|
|
9316
9214
|
}
|
|
9317
9215
|
|
|
9318
|
-
function
|
|
9216
|
+
function parseJSXMemberExpression() {
|
|
9319
9217
|
var marker = markerCreate(),
|
|
9320
|
-
expr =
|
|
9218
|
+
expr = parseJSXIdentifier();
|
|
9321
9219
|
|
|
9322
9220
|
while (match('.')) {
|
|
9323
9221
|
lex();
|
|
9324
|
-
expr = markerApply(marker, delegate.
|
|
9222
|
+
expr = markerApply(marker, delegate.createJSXMemberExpression(expr, parseJSXIdentifier()));
|
|
9325
9223
|
}
|
|
9326
9224
|
|
|
9327
9225
|
return expr;
|
|
9328
9226
|
}
|
|
9329
9227
|
|
|
9330
|
-
function
|
|
9228
|
+
function parseJSXElementName() {
|
|
9331
9229
|
if (lookahead2().value === ':') {
|
|
9332
|
-
return
|
|
9230
|
+
return parseJSXNamespacedName();
|
|
9333
9231
|
}
|
|
9334
9232
|
if (lookahead2().value === '.') {
|
|
9335
|
-
return
|
|
9233
|
+
return parseJSXMemberExpression();
|
|
9336
9234
|
}
|
|
9337
9235
|
|
|
9338
|
-
return
|
|
9236
|
+
return parseJSXIdentifier();
|
|
9339
9237
|
}
|
|
9340
9238
|
|
|
9341
|
-
function
|
|
9239
|
+
function parseJSXAttributeName() {
|
|
9342
9240
|
if (lookahead2().value === ':') {
|
|
9343
|
-
return
|
|
9241
|
+
return parseJSXNamespacedName();
|
|
9344
9242
|
}
|
|
9345
9243
|
|
|
9346
|
-
return
|
|
9244
|
+
return parseJSXIdentifier();
|
|
9347
9245
|
}
|
|
9348
9246
|
|
|
9349
|
-
function
|
|
9247
|
+
function parseJSXAttributeValue() {
|
|
9350
9248
|
var value, marker;
|
|
9351
9249
|
if (match('{')) {
|
|
9352
|
-
value =
|
|
9353
|
-
if (value.expression.type === Syntax.
|
|
9250
|
+
value = parseJSXExpressionContainer();
|
|
9251
|
+
if (value.expression.type === Syntax.JSXEmptyExpression) {
|
|
9354
9252
|
throwError(
|
|
9355
9253
|
value,
|
|
9356
|
-
'
|
|
9254
|
+
'JSX attributes must only be assigned a non-empty ' +
|
|
9357
9255
|
'expression'
|
|
9358
9256
|
);
|
|
9359
9257
|
}
|
|
9360
9258
|
} else if (match('<')) {
|
|
9361
|
-
value =
|
|
9362
|
-
} else if (lookahead.type === Token.
|
|
9259
|
+
value = parseJSXElement();
|
|
9260
|
+
} else if (lookahead.type === Token.JSXText) {
|
|
9363
9261
|
marker = markerCreate();
|
|
9364
9262
|
value = markerApply(marker, delegate.createLiteral(lex()));
|
|
9365
9263
|
} else {
|
|
9366
|
-
throwError({}, Messages.
|
|
9264
|
+
throwError({}, Messages.InvalidJSXAttributeValue);
|
|
9367
9265
|
}
|
|
9368
9266
|
return value;
|
|
9369
9267
|
}
|
|
9370
9268
|
|
|
9371
|
-
function
|
|
9269
|
+
function parseJSXEmptyExpression() {
|
|
9372
9270
|
var marker = markerCreatePreserveWhitespace();
|
|
9373
9271
|
while (source.charAt(index) !== '}') {
|
|
9374
9272
|
index++;
|
|
9375
9273
|
}
|
|
9376
|
-
return markerApply(marker, delegate.
|
|
9274
|
+
return markerApply(marker, delegate.createJSXEmptyExpression());
|
|
9377
9275
|
}
|
|
9378
9276
|
|
|
9379
|
-
function
|
|
9380
|
-
var expression,
|
|
9277
|
+
function parseJSXExpressionContainer() {
|
|
9278
|
+
var expression, origInJSXChild, origInJSXTag, marker = markerCreate();
|
|
9381
9279
|
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
state.
|
|
9385
|
-
state.
|
|
9280
|
+
origInJSXChild = state.inJSXChild;
|
|
9281
|
+
origInJSXTag = state.inJSXTag;
|
|
9282
|
+
state.inJSXChild = false;
|
|
9283
|
+
state.inJSXTag = false;
|
|
9386
9284
|
|
|
9387
9285
|
expect('{');
|
|
9388
9286
|
|
|
9389
9287
|
if (match('}')) {
|
|
9390
|
-
expression =
|
|
9288
|
+
expression = parseJSXEmptyExpression();
|
|
9391
9289
|
} else {
|
|
9392
9290
|
expression = parseExpression();
|
|
9393
9291
|
}
|
|
9394
9292
|
|
|
9395
|
-
state.
|
|
9396
|
-
state.
|
|
9293
|
+
state.inJSXChild = origInJSXChild;
|
|
9294
|
+
state.inJSXTag = origInJSXTag;
|
|
9397
9295
|
|
|
9398
9296
|
expect('}');
|
|
9399
9297
|
|
|
9400
|
-
return markerApply(marker, delegate.
|
|
9298
|
+
return markerApply(marker, delegate.createJSXExpressionContainer(expression));
|
|
9401
9299
|
}
|
|
9402
9300
|
|
|
9403
|
-
function
|
|
9404
|
-
var expression,
|
|
9301
|
+
function parseJSXSpreadAttribute() {
|
|
9302
|
+
var expression, origInJSXChild, origInJSXTag, marker = markerCreate();
|
|
9405
9303
|
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
state.
|
|
9409
|
-
state.
|
|
9304
|
+
origInJSXChild = state.inJSXChild;
|
|
9305
|
+
origInJSXTag = state.inJSXTag;
|
|
9306
|
+
state.inJSXChild = false;
|
|
9307
|
+
state.inJSXTag = false;
|
|
9410
9308
|
|
|
9411
9309
|
expect('{');
|
|
9412
9310
|
expect('...');
|
|
9413
9311
|
|
|
9414
9312
|
expression = parseAssignmentExpression();
|
|
9415
9313
|
|
|
9416
|
-
state.
|
|
9417
|
-
state.
|
|
9314
|
+
state.inJSXChild = origInJSXChild;
|
|
9315
|
+
state.inJSXTag = origInJSXTag;
|
|
9418
9316
|
|
|
9419
9317
|
expect('}');
|
|
9420
9318
|
|
|
9421
|
-
return markerApply(marker, delegate.
|
|
9319
|
+
return markerApply(marker, delegate.createJSXSpreadAttribute(expression));
|
|
9422
9320
|
}
|
|
9423
9321
|
|
|
9424
|
-
function
|
|
9322
|
+
function parseJSXAttribute() {
|
|
9425
9323
|
var name, marker;
|
|
9426
9324
|
|
|
9427
9325
|
if (match('{')) {
|
|
9428
|
-
return
|
|
9326
|
+
return parseJSXSpreadAttribute();
|
|
9429
9327
|
}
|
|
9430
9328
|
|
|
9431
9329
|
marker = markerCreate();
|
|
9432
9330
|
|
|
9433
|
-
name =
|
|
9331
|
+
name = parseJSXAttributeName();
|
|
9434
9332
|
|
|
9435
9333
|
// HTML empty attribute
|
|
9436
9334
|
if (match('=')) {
|
|
9437
9335
|
lex();
|
|
9438
|
-
return markerApply(marker, delegate.
|
|
9336
|
+
return markerApply(marker, delegate.createJSXAttribute(name, parseJSXAttributeValue()));
|
|
9439
9337
|
}
|
|
9440
9338
|
|
|
9441
|
-
return markerApply(marker, delegate.
|
|
9339
|
+
return markerApply(marker, delegate.createJSXAttribute(name));
|
|
9442
9340
|
}
|
|
9443
9341
|
|
|
9444
|
-
function
|
|
9342
|
+
function parseJSXChild() {
|
|
9445
9343
|
var token, marker;
|
|
9446
9344
|
if (match('{')) {
|
|
9447
|
-
token =
|
|
9448
|
-
} else if (lookahead.type === Token.
|
|
9345
|
+
token = parseJSXExpressionContainer();
|
|
9346
|
+
} else if (lookahead.type === Token.JSXText) {
|
|
9449
9347
|
marker = markerCreatePreserveWhitespace();
|
|
9450
9348
|
token = markerApply(marker, delegate.createLiteral(lex()));
|
|
9451
9349
|
} else if (match('<')) {
|
|
9452
|
-
token =
|
|
9350
|
+
token = parseJSXElement();
|
|
9453
9351
|
} else {
|
|
9454
9352
|
throwUnexpected(lookahead);
|
|
9455
9353
|
}
|
|
9456
9354
|
return token;
|
|
9457
9355
|
}
|
|
9458
9356
|
|
|
9459
|
-
function
|
|
9460
|
-
var name,
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
state.
|
|
9464
|
-
state.
|
|
9357
|
+
function parseJSXClosingElement() {
|
|
9358
|
+
var name, origInJSXChild, origInJSXTag, marker = markerCreate();
|
|
9359
|
+
origInJSXChild = state.inJSXChild;
|
|
9360
|
+
origInJSXTag = state.inJSXTag;
|
|
9361
|
+
state.inJSXChild = false;
|
|
9362
|
+
state.inJSXTag = true;
|
|
9465
9363
|
expect('<');
|
|
9466
9364
|
expect('/');
|
|
9467
|
-
name =
|
|
9365
|
+
name = parseJSXElementName();
|
|
9468
9366
|
// Because advance() (called by lex() called by expect()) expects there
|
|
9469
9367
|
// to be a valid token after >, it needs to know whether to look for a
|
|
9470
|
-
// standard JS token or an
|
|
9471
|
-
state.
|
|
9472
|
-
state.
|
|
9368
|
+
// standard JS token or an JSX text node
|
|
9369
|
+
state.inJSXChild = origInJSXChild;
|
|
9370
|
+
state.inJSXTag = origInJSXTag;
|
|
9473
9371
|
expect('>');
|
|
9474
|
-
return markerApply(marker, delegate.
|
|
9372
|
+
return markerApply(marker, delegate.createJSXClosingElement(name));
|
|
9475
9373
|
}
|
|
9476
9374
|
|
|
9477
|
-
function
|
|
9478
|
-
var name,
|
|
9375
|
+
function parseJSXOpeningElement() {
|
|
9376
|
+
var name, attributes = [], selfClosing = false, origInJSXChild, origInJSXTag, marker = markerCreate();
|
|
9479
9377
|
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
state.
|
|
9483
|
-
state.
|
|
9378
|
+
origInJSXChild = state.inJSXChild;
|
|
9379
|
+
origInJSXTag = state.inJSXTag;
|
|
9380
|
+
state.inJSXChild = false;
|
|
9381
|
+
state.inJSXTag = true;
|
|
9484
9382
|
|
|
9485
9383
|
expect('<');
|
|
9486
9384
|
|
|
9487
|
-
name =
|
|
9385
|
+
name = parseJSXElementName();
|
|
9488
9386
|
|
|
9489
9387
|
while (index < length &&
|
|
9490
9388
|
lookahead.value !== '/' &&
|
|
9491
9389
|
lookahead.value !== '>') {
|
|
9492
|
-
attributes.push(
|
|
9390
|
+
attributes.push(parseJSXAttribute());
|
|
9493
9391
|
}
|
|
9494
9392
|
|
|
9495
|
-
state.
|
|
9393
|
+
state.inJSXTag = origInJSXTag;
|
|
9496
9394
|
|
|
9497
9395
|
if (lookahead.value === '/') {
|
|
9498
9396
|
expect('/');
|
|
9499
9397
|
// Because advance() (called by lex() called by expect()) expects
|
|
9500
9398
|
// there to be a valid token after >, it needs to know whether to
|
|
9501
|
-
// look for a standard JS token or an
|
|
9502
|
-
state.
|
|
9399
|
+
// look for a standard JS token or an JSX text node
|
|
9400
|
+
state.inJSXChild = origInJSXChild;
|
|
9503
9401
|
expect('>');
|
|
9504
9402
|
selfClosing = true;
|
|
9505
9403
|
} else {
|
|
9506
|
-
state.
|
|
9404
|
+
state.inJSXChild = true;
|
|
9507
9405
|
expect('>');
|
|
9508
9406
|
}
|
|
9509
|
-
return markerApply(marker, delegate.
|
|
9407
|
+
return markerApply(marker, delegate.createJSXOpeningElement(name, attributes, selfClosing));
|
|
9510
9408
|
}
|
|
9511
9409
|
|
|
9512
|
-
function
|
|
9513
|
-
var openingElement, closingElement = null, children = [],
|
|
9410
|
+
function parseJSXElement() {
|
|
9411
|
+
var openingElement, closingElement = null, children = [], origInJSXChild, origInJSXTag, marker = markerCreate();
|
|
9514
9412
|
|
|
9515
|
-
|
|
9516
|
-
|
|
9517
|
-
openingElement =
|
|
9413
|
+
origInJSXChild = state.inJSXChild;
|
|
9414
|
+
origInJSXTag = state.inJSXTag;
|
|
9415
|
+
openingElement = parseJSXOpeningElement();
|
|
9518
9416
|
|
|
9519
9417
|
if (!openingElement.selfClosing) {
|
|
9520
9418
|
while (index < length) {
|
|
9521
|
-
state.
|
|
9419
|
+
state.inJSXChild = false; // Call lookahead2() with inJSXChild = false because </ should not be considered in the child
|
|
9522
9420
|
if (lookahead.value === '<' && lookahead2().value === '/') {
|
|
9523
9421
|
break;
|
|
9524
9422
|
}
|
|
9525
|
-
state.
|
|
9526
|
-
children.push(
|
|
9423
|
+
state.inJSXChild = true;
|
|
9424
|
+
children.push(parseJSXChild());
|
|
9527
9425
|
}
|
|
9528
|
-
state.
|
|
9529
|
-
state.
|
|
9530
|
-
closingElement =
|
|
9531
|
-
if (
|
|
9532
|
-
throwError({}, Messages.
|
|
9426
|
+
state.inJSXChild = origInJSXChild;
|
|
9427
|
+
state.inJSXTag = origInJSXTag;
|
|
9428
|
+
closingElement = parseJSXClosingElement();
|
|
9429
|
+
if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
|
|
9430
|
+
throwError({}, Messages.ExpectedJSXClosingTag, getQualifiedJSXName(openingElement.name));
|
|
9533
9431
|
}
|
|
9534
9432
|
}
|
|
9535
9433
|
|
|
@@ -9538,15 +9436,15 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
9538
9436
|
// var x = <div>one</div><div>two</div>;
|
|
9539
9437
|
//
|
|
9540
9438
|
// the default error message is a bit incomprehensible. Since it's
|
|
9541
|
-
// rarely (never?) useful to write a less-than sign after an
|
|
9439
|
+
// rarely (never?) useful to write a less-than sign after an JSX
|
|
9542
9440
|
// element, we disallow it here in the parser in order to provide a
|
|
9543
9441
|
// better error message. (In the rare case that the less-than operator
|
|
9544
9442
|
// was intended, the left tag can be wrapped in parentheses.)
|
|
9545
|
-
if (!
|
|
9546
|
-
throwError(lookahead, Messages.
|
|
9443
|
+
if (!origInJSXChild && match('<')) {
|
|
9444
|
+
throwError(lookahead, Messages.AdjacentJSXElements);
|
|
9547
9445
|
}
|
|
9548
9446
|
|
|
9549
|
-
return markerApply(marker, delegate.
|
|
9447
|
+
return markerApply(marker, delegate.createJSXElement(openingElement, closingElement, children));
|
|
9550
9448
|
}
|
|
9551
9449
|
|
|
9552
9450
|
function parseTypeAlias() {
|
|
@@ -9609,8 +9507,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
9609
9507
|
}
|
|
9610
9508
|
|
|
9611
9509
|
function parseInterface() {
|
|
9612
|
-
var
|
|
9613
|
-
typeParameters = null, previousStrict;
|
|
9510
|
+
var marker = markerCreate();
|
|
9614
9511
|
|
|
9615
9512
|
if (strict) {
|
|
9616
9513
|
expectKeyword('interface');
|
|
@@ -9728,14 +9625,13 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
9728
9625
|
}
|
|
9729
9626
|
|
|
9730
9627
|
function collectToken() {
|
|
9731
|
-
var
|
|
9628
|
+
var loc, token, range, value, entry;
|
|
9732
9629
|
|
|
9733
9630
|
/* istanbul ignore else */
|
|
9734
|
-
if (!state.
|
|
9631
|
+
if (!state.inJSXChild) {
|
|
9735
9632
|
skipComment();
|
|
9736
9633
|
}
|
|
9737
9634
|
|
|
9738
|
-
start = index;
|
|
9739
9635
|
loc = {
|
|
9740
9636
|
start: {
|
|
9741
9637
|
line: lineNumber,
|
|
@@ -9841,11 +9737,6 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
9841
9737
|
}
|
|
9842
9738
|
|
|
9843
9739
|
function patch() {
|
|
9844
|
-
if (extra.comments) {
|
|
9845
|
-
extra.skipComment = skipComment;
|
|
9846
|
-
skipComment = scanComment;
|
|
9847
|
-
}
|
|
9848
|
-
|
|
9849
9740
|
if (typeof extra.tokens !== 'undefined') {
|
|
9850
9741
|
extra.advance = advance;
|
|
9851
9742
|
extra.scanRegExp = scanRegExp;
|
|
@@ -9856,10 +9747,6 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
9856
9747
|
}
|
|
9857
9748
|
|
|
9858
9749
|
function unpatch() {
|
|
9859
|
-
if (typeof extra.skipComment === 'function') {
|
|
9860
|
-
skipComment = extra.skipComment;
|
|
9861
|
-
}
|
|
9862
|
-
|
|
9863
9750
|
if (typeof extra.scanRegExp === 'function') {
|
|
9864
9751
|
advance = extra.advance;
|
|
9865
9752
|
scanRegExp = extra.scanRegExp;
|
|
@@ -10003,8 +9890,8 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
10003
9890
|
inFunctionBody: false,
|
|
10004
9891
|
inIteration: false,
|
|
10005
9892
|
inSwitch: false,
|
|
10006
|
-
|
|
10007
|
-
|
|
9893
|
+
inJSXChild: false,
|
|
9894
|
+
inJSXTag: false,
|
|
10008
9895
|
inType: false,
|
|
10009
9896
|
lastCommentStart: -1,
|
|
10010
9897
|
yieldAllowed: false,
|
|
@@ -10069,7 +9956,7 @@ parseYieldExpression: true, parseAwaitExpression: true
|
|
|
10069
9956
|
}
|
|
10070
9957
|
|
|
10071
9958
|
// Sync with *.json manifests.
|
|
10072
|
-
exports.version = '
|
|
9959
|
+
exports.version = '13001.1.0-dev-harmony-fb';
|
|
10073
9960
|
|
|
10074
9961
|
exports.tokenize = tokenize;
|
|
10075
9962
|
|
|
@@ -15125,10 +15012,35 @@ RESERVED_WORDS.forEach(function(k) {
|
|
|
15125
15012
|
reservedWordsMap[k] = true;
|
|
15126
15013
|
});
|
|
15127
15014
|
|
|
15015
|
+
/**
|
|
15016
|
+
* This list should not grow as new reserved words are introdued. This list is
|
|
15017
|
+
* of words that need to be quoted because ES3-ish browsers do not allow their
|
|
15018
|
+
* use as identifier names.
|
|
15019
|
+
*/
|
|
15020
|
+
var ES3_FUTURE_RESERVED_WORDS = [
|
|
15021
|
+
'enum', 'implements', 'package', 'protected', 'static', 'interface',
|
|
15022
|
+
'private', 'public'
|
|
15023
|
+
];
|
|
15024
|
+
|
|
15025
|
+
var ES3_RESERVED_WORDS = [].concat(
|
|
15026
|
+
KEYWORDS,
|
|
15027
|
+
ES3_FUTURE_RESERVED_WORDS,
|
|
15028
|
+
LITERALS
|
|
15029
|
+
);
|
|
15030
|
+
|
|
15031
|
+
var es3ReservedWordsMap = Object.create(null);
|
|
15032
|
+
ES3_RESERVED_WORDS.forEach(function(k) {
|
|
15033
|
+
es3ReservedWordsMap[k] = true;
|
|
15034
|
+
});
|
|
15035
|
+
|
|
15128
15036
|
exports.isReservedWord = function(word) {
|
|
15129
15037
|
return !!reservedWordsMap[word];
|
|
15130
15038
|
};
|
|
15131
15039
|
|
|
15040
|
+
exports.isES3ReservedWord = function(word) {
|
|
15041
|
+
return !!es3ReservedWordsMap[word];
|
|
15042
|
+
};
|
|
15043
|
+
|
|
15132
15044
|
},{}],35:[function(_dereq_,module,exports){
|
|
15133
15045
|
/**
|
|
15134
15046
|
* Copyright 2014 Facebook, Inc.
|
|
@@ -15174,7 +15086,7 @@ visitProperty.test = function(node) {
|
|
|
15174
15086
|
!node.method &&
|
|
15175
15087
|
!node.shorthand &&
|
|
15176
15088
|
!node.computed &&
|
|
15177
|
-
reserverdWordsHelper.
|
|
15089
|
+
reserverdWordsHelper.isES3ReservedWord(node.key.name);
|
|
15178
15090
|
};
|
|
15179
15091
|
|
|
15180
15092
|
function visitMemberExpression(traverse, node, path, state) {
|
|
@@ -15191,7 +15103,7 @@ function visitMemberExpression(traverse, node, path, state) {
|
|
|
15191
15103
|
visitMemberExpression.test = function(node) {
|
|
15192
15104
|
return node.type === Syntax.MemberExpression &&
|
|
15193
15105
|
node.property.type === Syntax.Identifier &&
|
|
15194
|
-
reserverdWordsHelper.
|
|
15106
|
+
reserverdWordsHelper.isES3ReservedWord(node.property.name);
|
|
15195
15107
|
};
|
|
15196
15108
|
|
|
15197
15109
|
exports.visitorList = [
|
|
@@ -15229,6 +15141,10 @@ visitTypeAlias.test = function(node, path, state) {
|
|
|
15229
15141
|
};
|
|
15230
15142
|
|
|
15231
15143
|
function visitTypeCast(traverse, node, path, state) {
|
|
15144
|
+
path.unshift(node);
|
|
15145
|
+
traverse(node.expression, path, state);
|
|
15146
|
+
path.shift();
|
|
15147
|
+
|
|
15232
15148
|
utils.catchup(node.typeAnnotation.range[0], state);
|
|
15233
15149
|
utils.catchupWhiteOut(node.typeAnnotation.range[1], state);
|
|
15234
15150
|
return false;
|
|
@@ -15380,16 +15296,129 @@ exports.visitorList = [
|
|
|
15380
15296
|
*/
|
|
15381
15297
|
/*global exports:true*/
|
|
15382
15298
|
'use strict';
|
|
15299
|
+
var Syntax = _dereq_('jstransform').Syntax;
|
|
15300
|
+
var utils = _dereq_('jstransform/src/utils');
|
|
15301
|
+
|
|
15302
|
+
function renderJSXLiteral(object, isLast, state, start, end) {
|
|
15303
|
+
var lines = object.value.split(/\r\n|\n|\r/);
|
|
15304
|
+
|
|
15305
|
+
if (start) {
|
|
15306
|
+
utils.append(start, state);
|
|
15307
|
+
}
|
|
15308
|
+
|
|
15309
|
+
var lastNonEmptyLine = 0;
|
|
15310
|
+
|
|
15311
|
+
lines.forEach(function(line, index) {
|
|
15312
|
+
if (line.match(/[^ \t]/)) {
|
|
15313
|
+
lastNonEmptyLine = index;
|
|
15314
|
+
}
|
|
15315
|
+
});
|
|
15316
|
+
|
|
15317
|
+
lines.forEach(function(line, index) {
|
|
15318
|
+
var isFirstLine = index === 0;
|
|
15319
|
+
var isLastLine = index === lines.length - 1;
|
|
15320
|
+
var isLastNonEmptyLine = index === lastNonEmptyLine;
|
|
15321
|
+
|
|
15322
|
+
// replace rendered whitespace tabs with spaces
|
|
15323
|
+
var trimmedLine = line.replace(/\t/g, ' ');
|
|
15324
|
+
|
|
15325
|
+
// trim whitespace touching a newline
|
|
15326
|
+
if (!isFirstLine) {
|
|
15327
|
+
trimmedLine = trimmedLine.replace(/^[ ]+/, '');
|
|
15328
|
+
}
|
|
15329
|
+
if (!isLastLine) {
|
|
15330
|
+
trimmedLine = trimmedLine.replace(/[ ]+$/, '');
|
|
15331
|
+
}
|
|
15332
|
+
|
|
15333
|
+
if (!isFirstLine) {
|
|
15334
|
+
utils.append(line.match(/^[ \t]*/)[0], state);
|
|
15335
|
+
}
|
|
15336
|
+
|
|
15337
|
+
if (trimmedLine || isLastNonEmptyLine) {
|
|
15338
|
+
utils.append(
|
|
15339
|
+
JSON.stringify(trimmedLine) +
|
|
15340
|
+
(!isLastNonEmptyLine ? ' + \' \' +' : ''),
|
|
15341
|
+
state);
|
|
15342
|
+
|
|
15343
|
+
if (isLastNonEmptyLine) {
|
|
15344
|
+
if (end) {
|
|
15345
|
+
utils.append(end, state);
|
|
15346
|
+
}
|
|
15347
|
+
if (!isLast) {
|
|
15348
|
+
utils.append(', ', state);
|
|
15349
|
+
}
|
|
15350
|
+
}
|
|
15351
|
+
|
|
15352
|
+
// only restore tail whitespace if line had literals
|
|
15353
|
+
if (trimmedLine && !isLastLine) {
|
|
15354
|
+
utils.append(line.match(/[ \t]*$/)[0], state);
|
|
15355
|
+
}
|
|
15356
|
+
}
|
|
15357
|
+
|
|
15358
|
+
if (!isLastLine) {
|
|
15359
|
+
utils.append('\n', state);
|
|
15360
|
+
}
|
|
15361
|
+
});
|
|
15362
|
+
|
|
15363
|
+
utils.move(object.range[1], state);
|
|
15364
|
+
}
|
|
15365
|
+
|
|
15366
|
+
function renderJSXExpressionContainer(traverse, object, isLast, path, state) {
|
|
15367
|
+
// Plus 1 to skip `{`.
|
|
15368
|
+
utils.move(object.range[0] + 1, state);
|
|
15369
|
+
utils.catchup(object.expression.range[0], state);
|
|
15370
|
+
traverse(object.expression, path, state);
|
|
15371
|
+
|
|
15372
|
+
if (!isLast && object.expression.type !== Syntax.JSXEmptyExpression) {
|
|
15373
|
+
// If we need to append a comma, make sure to do so after the expression.
|
|
15374
|
+
utils.catchup(object.expression.range[1], state, trimLeft);
|
|
15375
|
+
utils.append(', ', state);
|
|
15376
|
+
}
|
|
15377
|
+
|
|
15378
|
+
// Minus 1 to skip `}`.
|
|
15379
|
+
utils.catchup(object.range[1] - 1, state, trimLeft);
|
|
15380
|
+
utils.move(object.range[1], state);
|
|
15381
|
+
return false;
|
|
15382
|
+
}
|
|
15383
|
+
|
|
15384
|
+
function quoteAttrName(attr) {
|
|
15385
|
+
// Quote invalid JS identifiers.
|
|
15386
|
+
if (!/^[a-z_$][a-z\d_$]*$/i.test(attr)) {
|
|
15387
|
+
return '"' + attr + '"';
|
|
15388
|
+
}
|
|
15389
|
+
return attr;
|
|
15390
|
+
}
|
|
15391
|
+
|
|
15392
|
+
function trimLeft(value) {
|
|
15393
|
+
return value.replace(/^[ ]+/, '');
|
|
15394
|
+
}
|
|
15395
|
+
|
|
15396
|
+
exports.renderJSXExpressionContainer = renderJSXExpressionContainer;
|
|
15397
|
+
exports.renderJSXLiteral = renderJSXLiteral;
|
|
15398
|
+
exports.quoteAttrName = quoteAttrName;
|
|
15399
|
+
exports.trimLeft = trimLeft;
|
|
15400
|
+
|
|
15401
|
+
},{"jstransform":22,"jstransform/src/utils":23}],38:[function(_dereq_,module,exports){
|
|
15402
|
+
/**
|
|
15403
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
15404
|
+
* All rights reserved.
|
|
15405
|
+
*
|
|
15406
|
+
* This source code is licensed under the BSD-style license found in the
|
|
15407
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
15408
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15409
|
+
*/
|
|
15410
|
+
/*global exports:true*/
|
|
15411
|
+
'use strict';
|
|
15383
15412
|
|
|
15384
15413
|
var Syntax = _dereq_('jstransform').Syntax;
|
|
15385
15414
|
var utils = _dereq_('jstransform/src/utils');
|
|
15386
15415
|
|
|
15387
|
-
var
|
|
15388
|
-
_dereq_('./
|
|
15389
|
-
var
|
|
15390
|
-
var quoteAttrName = _dereq_('./
|
|
15416
|
+
var renderJSXExpressionContainer =
|
|
15417
|
+
_dereq_('./jsx').renderJSXExpressionContainer;
|
|
15418
|
+
var renderJSXLiteral = _dereq_('./jsx').renderJSXLiteral;
|
|
15419
|
+
var quoteAttrName = _dereq_('./jsx').quoteAttrName;
|
|
15391
15420
|
|
|
15392
|
-
var trimLeft = _dereq_('./
|
|
15421
|
+
var trimLeft = _dereq_('./jsx').trimLeft;
|
|
15393
15422
|
|
|
15394
15423
|
/**
|
|
15395
15424
|
* Customized desugar processor for React JSX. Currently:
|
|
@@ -15422,20 +15451,20 @@ function visitReactTag(traverse, object, path, state) {
|
|
|
15422
15451
|
|
|
15423
15452
|
utils.catchup(openingElement.range[0], state, trimLeft);
|
|
15424
15453
|
|
|
15425
|
-
if (nameObject.type === Syntax.
|
|
15454
|
+
if (nameObject.type === Syntax.JSXNamespacedName && nameObject.namespace) {
|
|
15426
15455
|
throw new Error('Namespace tags are not supported. ReactJSX is not XML.');
|
|
15427
15456
|
}
|
|
15428
15457
|
|
|
15429
15458
|
// We assume that the React runtime is already in scope
|
|
15430
15459
|
utils.append('React.createElement(', state);
|
|
15431
15460
|
|
|
15432
|
-
if (nameObject.type === Syntax.
|
|
15461
|
+
if (nameObject.type === Syntax.JSXIdentifier && isTagName(nameObject.name)) {
|
|
15433
15462
|
utils.append('"' + nameObject.name + '"', state);
|
|
15434
15463
|
utils.move(nameObject.range[1], state);
|
|
15435
15464
|
} else {
|
|
15436
15465
|
// Use utils.catchup in this case so we can easily handle
|
|
15437
|
-
//
|
|
15438
|
-
//
|
|
15466
|
+
// JSXMemberExpressions which look like Foo.Bar.Baz. This also handles
|
|
15467
|
+
// JSXIdentifiers that aren't fallback tags.
|
|
15439
15468
|
utils.move(nameObject.range[0], state);
|
|
15440
15469
|
utils.catchup(nameObject.range[1], state);
|
|
15441
15470
|
}
|
|
@@ -15445,7 +15474,7 @@ function visitReactTag(traverse, object, path, state) {
|
|
|
15445
15474
|
var hasAttributes = attributesObject.length;
|
|
15446
15475
|
|
|
15447
15476
|
var hasAtLeastOneSpreadProperty = attributesObject.some(function(attr) {
|
|
15448
|
-
return attr.type === Syntax.
|
|
15477
|
+
return attr.type === Syntax.JSXSpreadAttribute;
|
|
15449
15478
|
});
|
|
15450
15479
|
|
|
15451
15480
|
// if we don't have any attributes, pass in null
|
|
@@ -15464,7 +15493,7 @@ function visitReactTag(traverse, object, path, state) {
|
|
|
15464
15493
|
attributesObject.forEach(function(attr, index) {
|
|
15465
15494
|
var isLast = index === attributesObject.length - 1;
|
|
15466
15495
|
|
|
15467
|
-
if (attr.type === Syntax.
|
|
15496
|
+
if (attr.type === Syntax.JSXSpreadAttribute) {
|
|
15468
15497
|
// Close the previous object or initial object
|
|
15469
15498
|
if (!previousWasSpread) {
|
|
15470
15499
|
utils.append('}, ', state);
|
|
@@ -15497,7 +15526,7 @@ function visitReactTag(traverse, object, path, state) {
|
|
|
15497
15526
|
|
|
15498
15527
|
// If the next attribute is a spread, we're effective last in this object
|
|
15499
15528
|
if (!isLast) {
|
|
15500
|
-
isLast = attributesObject[index + 1].type === Syntax.
|
|
15529
|
+
isLast = attributesObject[index + 1].type === Syntax.JSXSpreadAttribute;
|
|
15501
15530
|
}
|
|
15502
15531
|
|
|
15503
15532
|
if (attr.name.namespace) {
|
|
@@ -15526,9 +15555,9 @@ function visitReactTag(traverse, object, path, state) {
|
|
|
15526
15555
|
// Use catchupNewlines to skip over the '=' in the attribute
|
|
15527
15556
|
utils.catchupNewlines(attr.value.range[0], state);
|
|
15528
15557
|
if (attr.value.type === Syntax.Literal) {
|
|
15529
|
-
|
|
15558
|
+
renderJSXLiteral(attr.value, isLast, state);
|
|
15530
15559
|
} else {
|
|
15531
|
-
|
|
15560
|
+
renderJSXExpressionContainer(traverse, attr.value, isLast, path, state);
|
|
15532
15561
|
}
|
|
15533
15562
|
}
|
|
15534
15563
|
|
|
@@ -15561,8 +15590,8 @@ function visitReactTag(traverse, object, path, state) {
|
|
|
15561
15590
|
var lastRenderableIndex;
|
|
15562
15591
|
|
|
15563
15592
|
childrenToRender.forEach(function(child, index) {
|
|
15564
|
-
if (child.type !== Syntax.
|
|
15565
|
-
child.expression.type !== Syntax.
|
|
15593
|
+
if (child.type !== Syntax.JSXExpressionContainer ||
|
|
15594
|
+
child.expression.type !== Syntax.JSXEmptyExpression) {
|
|
15566
15595
|
lastRenderableIndex = index;
|
|
15567
15596
|
}
|
|
15568
15597
|
});
|
|
@@ -15577,9 +15606,9 @@ function visitReactTag(traverse, object, path, state) {
|
|
|
15577
15606
|
var isLast = index >= lastRenderableIndex;
|
|
15578
15607
|
|
|
15579
15608
|
if (child.type === Syntax.Literal) {
|
|
15580
|
-
|
|
15581
|
-
} else if (child.type === Syntax.
|
|
15582
|
-
|
|
15609
|
+
renderJSXLiteral(child, isLast, state);
|
|
15610
|
+
} else if (child.type === Syntax.JSXExpressionContainer) {
|
|
15611
|
+
renderJSXExpressionContainer(traverse, child, isLast, path, state);
|
|
15583
15612
|
} else {
|
|
15584
15613
|
traverse(child, path, state);
|
|
15585
15614
|
if (!isLast) {
|
|
@@ -15606,14 +15635,14 @@ function visitReactTag(traverse, object, path, state) {
|
|
|
15606
15635
|
}
|
|
15607
15636
|
|
|
15608
15637
|
visitReactTag.test = function(object, path, state) {
|
|
15609
|
-
return object.type === Syntax.
|
|
15638
|
+
return object.type === Syntax.JSXElement;
|
|
15610
15639
|
};
|
|
15611
15640
|
|
|
15612
15641
|
exports.visitorList = [
|
|
15613
15642
|
visitReactTag
|
|
15614
15643
|
];
|
|
15615
15644
|
|
|
15616
|
-
},{"./
|
|
15645
|
+
},{"./jsx":37,"jstransform":22,"jstransform/src/utils":23}],39:[function(_dereq_,module,exports){
|
|
15617
15646
|
/**
|
|
15618
15647
|
* Copyright 2013-2015, Facebook, Inc.
|
|
15619
15648
|
* All rights reserved.
|
|
@@ -15708,119 +15737,6 @@ exports.visitorList = [
|
|
|
15708
15737
|
visitReactDisplayName
|
|
15709
15738
|
];
|
|
15710
15739
|
|
|
15711
|
-
},{"jstransform":22,"jstransform/src/utils":23}],39:[function(_dereq_,module,exports){
|
|
15712
|
-
/**
|
|
15713
|
-
* Copyright 2013-2015, Facebook, Inc.
|
|
15714
|
-
* All rights reserved.
|
|
15715
|
-
*
|
|
15716
|
-
* This source code is licensed under the BSD-style license found in the
|
|
15717
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
15718
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15719
|
-
*/
|
|
15720
|
-
/*global exports:true*/
|
|
15721
|
-
'use strict';
|
|
15722
|
-
var Syntax = _dereq_('jstransform').Syntax;
|
|
15723
|
-
var utils = _dereq_('jstransform/src/utils');
|
|
15724
|
-
|
|
15725
|
-
function renderXJSLiteral(object, isLast, state, start, end) {
|
|
15726
|
-
var lines = object.value.split(/\r\n|\n|\r/);
|
|
15727
|
-
|
|
15728
|
-
if (start) {
|
|
15729
|
-
utils.append(start, state);
|
|
15730
|
-
}
|
|
15731
|
-
|
|
15732
|
-
var lastNonEmptyLine = 0;
|
|
15733
|
-
|
|
15734
|
-
lines.forEach(function(line, index) {
|
|
15735
|
-
if (line.match(/[^ \t]/)) {
|
|
15736
|
-
lastNonEmptyLine = index;
|
|
15737
|
-
}
|
|
15738
|
-
});
|
|
15739
|
-
|
|
15740
|
-
lines.forEach(function(line, index) {
|
|
15741
|
-
var isFirstLine = index === 0;
|
|
15742
|
-
var isLastLine = index === lines.length - 1;
|
|
15743
|
-
var isLastNonEmptyLine = index === lastNonEmptyLine;
|
|
15744
|
-
|
|
15745
|
-
// replace rendered whitespace tabs with spaces
|
|
15746
|
-
var trimmedLine = line.replace(/\t/g, ' ');
|
|
15747
|
-
|
|
15748
|
-
// trim whitespace touching a newline
|
|
15749
|
-
if (!isFirstLine) {
|
|
15750
|
-
trimmedLine = trimmedLine.replace(/^[ ]+/, '');
|
|
15751
|
-
}
|
|
15752
|
-
if (!isLastLine) {
|
|
15753
|
-
trimmedLine = trimmedLine.replace(/[ ]+$/, '');
|
|
15754
|
-
}
|
|
15755
|
-
|
|
15756
|
-
if (!isFirstLine) {
|
|
15757
|
-
utils.append(line.match(/^[ \t]*/)[0], state);
|
|
15758
|
-
}
|
|
15759
|
-
|
|
15760
|
-
if (trimmedLine || isLastNonEmptyLine) {
|
|
15761
|
-
utils.append(
|
|
15762
|
-
JSON.stringify(trimmedLine) +
|
|
15763
|
-
(!isLastNonEmptyLine ? ' + \' \' +' : ''),
|
|
15764
|
-
state);
|
|
15765
|
-
|
|
15766
|
-
if (isLastNonEmptyLine) {
|
|
15767
|
-
if (end) {
|
|
15768
|
-
utils.append(end, state);
|
|
15769
|
-
}
|
|
15770
|
-
if (!isLast) {
|
|
15771
|
-
utils.append(', ', state);
|
|
15772
|
-
}
|
|
15773
|
-
}
|
|
15774
|
-
|
|
15775
|
-
// only restore tail whitespace if line had literals
|
|
15776
|
-
if (trimmedLine && !isLastLine) {
|
|
15777
|
-
utils.append(line.match(/[ \t]*$/)[0], state);
|
|
15778
|
-
}
|
|
15779
|
-
}
|
|
15780
|
-
|
|
15781
|
-
if (!isLastLine) {
|
|
15782
|
-
utils.append('\n', state);
|
|
15783
|
-
}
|
|
15784
|
-
});
|
|
15785
|
-
|
|
15786
|
-
utils.move(object.range[1], state);
|
|
15787
|
-
}
|
|
15788
|
-
|
|
15789
|
-
function renderXJSExpressionContainer(traverse, object, isLast, path, state) {
|
|
15790
|
-
// Plus 1 to skip `{`.
|
|
15791
|
-
utils.move(object.range[0] + 1, state);
|
|
15792
|
-
utils.catchup(object.expression.range[0], state);
|
|
15793
|
-
traverse(object.expression, path, state);
|
|
15794
|
-
|
|
15795
|
-
if (!isLast && object.expression.type !== Syntax.XJSEmptyExpression) {
|
|
15796
|
-
// If we need to append a comma, make sure to do so after the expression.
|
|
15797
|
-
utils.catchup(object.expression.range[1], state, trimLeft);
|
|
15798
|
-
utils.append(', ', state);
|
|
15799
|
-
}
|
|
15800
|
-
|
|
15801
|
-
// Minus 1 to skip `}`.
|
|
15802
|
-
utils.catchup(object.range[1] - 1, state, trimLeft);
|
|
15803
|
-
utils.move(object.range[1], state);
|
|
15804
|
-
return false;
|
|
15805
|
-
}
|
|
15806
|
-
|
|
15807
|
-
function quoteAttrName(attr) {
|
|
15808
|
-
// Quote invalid JS identifiers.
|
|
15809
|
-
if (!/^[a-z_$][a-z\d_$]*$/i.test(attr)) {
|
|
15810
|
-
return '"' + attr + '"';
|
|
15811
|
-
}
|
|
15812
|
-
return attr;
|
|
15813
|
-
}
|
|
15814
|
-
|
|
15815
|
-
function trimLeft(value) {
|
|
15816
|
-
return value.replace(/^[ ]+/, '');
|
|
15817
|
-
}
|
|
15818
|
-
|
|
15819
|
-
exports.renderXJSExpressionContainer = renderXJSExpressionContainer;
|
|
15820
|
-
exports.renderXJSLiteral = renderXJSLiteral;
|
|
15821
|
-
exports.quoteAttrName = quoteAttrName;
|
|
15822
|
-
exports.trimLeft = trimLeft;
|
|
15823
|
-
|
|
15824
15740
|
},{"jstransform":22,"jstransform/src/utils":23}],40:[function(_dereq_,module,exports){
|
|
15825
15741
|
/*global exports:true*/
|
|
15826
15742
|
|
|
@@ -15948,7 +15864,7 @@ exports.getVisitorsBySet = getVisitorsBySet;
|
|
|
15948
15864
|
exports.getAllVisitors = getAllVisitors;
|
|
15949
15865
|
exports.transformVisitors = transformVisitors;
|
|
15950
15866
|
|
|
15951
|
-
},{"./transforms/react":
|
|
15867
|
+
},{"./transforms/react":38,"./transforms/reactDisplayName":39,"jstransform/visitors/es6-arrow-function-visitors":24,"jstransform/visitors/es6-call-spread-visitors":25,"jstransform/visitors/es6-class-visitors":26,"jstransform/visitors/es6-destructuring-visitors":27,"jstransform/visitors/es6-object-concise-method-visitors":28,"jstransform/visitors/es6-object-short-notation-visitors":29,"jstransform/visitors/es6-rest-param-visitors":30,"jstransform/visitors/es6-template-visitors":31,"jstransform/visitors/es7-spread-property-visitors":33,"jstransform/visitors/reserved-words-visitors":35}],41:[function(_dereq_,module,exports){
|
|
15952
15868
|
/**
|
|
15953
15869
|
* Copyright 2013-2015, Facebook, Inc.
|
|
15954
15870
|
* All rights reserved.
|