diff --git a/modules/@angular/compiler/src/html_lexer.ts b/modules/@angular/compiler/src/html_lexer.ts
index bfd1cd7777..1c063539d8 100644
--- a/modules/@angular/compiler/src/html_lexer.ts
+++ b/modules/@angular/compiler/src/html_lexer.ts
@@ -267,8 +267,16 @@ class _HtmlTokenizer {
}
private _attemptStr(chars: string): boolean {
+ var indexBeforeAttempt = this.index;
+ var columnBeforeAttempt = this.column;
+ var lineBeforeAttempt = this.line;
for (var i = 0; i < chars.length; i++) {
if (!this._attemptCharCode(StringWrapper.charCodeAt(chars, i))) {
+ // If attempting to parse the string fails, we want to reset the parser
+ // to where it was before the attempt
+ this.index = indexBeforeAttempt;
+ this.column = columnBeforeAttempt;
+ this.line = lineBeforeAttempt;
return false;
}
}
diff --git a/modules/@angular/compiler/test/html_lexer_spec.ts b/modules/@angular/compiler/test/html_lexer_spec.ts
index e0c08b045b..31089cbcc2 100644
--- a/modules/@angular/compiler/test/html_lexer_spec.ts
+++ b/modules/@angular/compiler/test/html_lexer_spec.ts
@@ -95,6 +95,26 @@ export function main() {
expect(tokenizeAndHumanizeErrors(''))
+ .toEqual([
+ [HtmlTokenType.COMMENT_START, ''],
+ [HtmlTokenType.EOF, '']
+ ]);
+ });
+
+ it('should accept comments finishing by too many dashes (odd number)', () => {
+ expect(tokenizeAndHumanizeSourceSpans(''))
+ .toEqual([
+ [HtmlTokenType.COMMENT_START, ''],
+ [HtmlTokenType.EOF, '']
+ ]);
+ });
});
describe('doctype', () => {