File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
modules/@angular/compiler Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,9 @@ class _HtmlTokenizer {
202
202
}
203
203
204
204
private _createError ( msg : string , span : ParseSourceSpan ) : _ControlFlowError {
205
+ if ( this . _isInExpansionForm ( ) ) {
206
+ msg += ' (Do you have an unescaped "{" in your template?).' ;
207
+ }
205
208
const error = new HtmlTokenError ( msg , this . _currentTokenType , span ) ;
206
209
this . _currentTokenStart = null ;
207
210
this . _currentTokenType = null ;
@@ -523,6 +526,8 @@ class _HtmlTokenizer {
523
526
this . _requireCharCode ( chars . $LBRACE ) ;
524
527
this . _endToken ( [ ] ) ;
525
528
529
+ this . _expansionCaseStack . push ( HtmlTokenType . EXPANSION_FORM_START ) ;
530
+
526
531
this . _beginToken ( HtmlTokenType . RAW_TEXT , this . _getLocation ( ) ) ;
527
532
const condition = this . _readUntil ( chars . $COMMA ) ;
528
533
this . _endToken ( [ condition ] , this . _getLocation ( ) ) ;
@@ -534,8 +539,6 @@ class _HtmlTokenizer {
534
539
this . _endToken ( [ type ] , this . _getLocation ( ) ) ;
535
540
this . _requireCharCode ( chars . $COMMA ) ;
536
541
this . _attemptCharCodeUntilFn ( isNotWhitespace ) ;
537
-
538
- this . _expansionCaseStack . push ( HtmlTokenType . EXPANSION_FORM_START ) ;
539
542
}
540
543
541
544
private _consumeExpansionCaseStart ( ) {
Original file line number Diff line number Diff line change @@ -728,6 +728,14 @@ export function main() {
728
728
} ) ;
729
729
730
730
describe ( 'errors' , ( ) => {
731
+ it ( 'should parse nested expansion forms' , ( ) => {
732
+ expect ( tokenizeAndHumanizeErrors ( `<p>before { after</p>` , true ) ) . toEqual ( [ [
733
+ HtmlTokenType . RAW_TEXT ,
734
+ 'Unexpected character "EOF" (Do you have an unescaped "{" in your template?).' ,
735
+ '0:21' ,
736
+ ] ] ) ;
737
+ } ) ;
738
+
731
739
it ( 'should include 2 lines of context in message' , ( ) => {
732
740
let src = '111\n222\n333\nE\n444\n555\n666\n' ;
733
741
let file = new ParseSourceFile ( src , 'file://' ) ;
@@ -787,7 +795,7 @@ function tokenizeAndHumanizeLineColumn(input: string): any[] {
787
795
token => [ < any > token . type , humanizeLineColumn ( token . sourceSpan . start ) ] ) ;
788
796
}
789
797
790
- function tokenizeAndHumanizeErrors ( input : string ) : any [ ] {
791
- return tokenizeHtml ( input , 'someUrl' )
798
+ function tokenizeAndHumanizeErrors ( input : string , tokenizeExpansionForms : boolean = false ) : any [ ] {
799
+ return tokenizeHtml ( input , 'someUrl' , tokenizeExpansionForms )
792
800
. errors . map ( e => [ < any > e . tokenType , e . msg , humanizeLineColumn ( e . span . start ) ] ) ;
793
801
}
You can’t perform that action at this time.
0 commit comments