Revert "feat(Compiler): case sensitive html parser"

This reverts commit a8edc1eb58.
This commit is contained in:
vsavkin
2015-11-16 14:36:39 -08:00
parent c5045ac8fe
commit 0611239a0e
13 changed files with 343 additions and 736 deletions

View File

@ -6,6 +6,7 @@ import {
CONST_EXPR,
serializeEnum
} from 'angular2/src/facade/lang';
import {BaseException} from 'angular2/src/facade/exceptions';
import {ParseLocation, ParseError, ParseSourceFile, ParseSourceSpan} from './parse_util';
import {getHtmlTagDefinition, HtmlTagContentType, NAMED_ENTITIES} from './html_tags';
@ -49,7 +50,6 @@ export function tokenizeHtml(sourceContent: string, sourceUrl: string): HtmlToke
const $EOF = 0;
const $TAB = 9;
const $LF = 10;
const $FF = 12;
const $CR = 13;
const $SPACE = 32;
@ -247,22 +247,17 @@ class _HtmlTokenizer {
}
}
private _readChar(decodeEntities: boolean, extraNotCharRef: number = null): string {
private _readChar(decodeEntities: boolean): string {
if (decodeEntities && this.peek === $AMPERSAND) {
var start = this._getLocation();
this._attemptUntilChar($SEMICOLON);
this._advance();
if (isCharRefStart(this.peek, extraNotCharRef)) {
this._attemptUntilChar($SEMICOLON);
this._advance();
var entitySrc = this.input.substring(start.offset + 1, this.index - 1);
var decodedEntity = decodeEntity(entitySrc);
if (isPresent(decodedEntity)) {
return decodedEntity;
} else {
throw this._createError(unknownEntityErrorMsg(entitySrc), start);
}
var entitySrc = this.input.substring(start.offset + 1, this.index - 1);
var decodedEntity = decodeEntity(entitySrc);
if (isPresent(decodedEntity)) {
return decodedEntity;
} else {
return '&';
throw this._createError(unknownEntityErrorMsg(entitySrc), start);
}
} else {
var index = this.index;
@ -394,7 +389,7 @@ class _HtmlTokenizer {
this._advance();
var parts = [];
while (this.peek !== quoteChar) {
parts.push(this._readChar(true, quoteChar));
parts.push(this._readChar(true));
}
value = parts.join('');
this._advance();
@ -445,13 +440,7 @@ function isWhitespace(code: number): boolean {
function isNameEnd(code: number): boolean {
return isWhitespace(code) || code === $GT || code === $SLASH || code === $SQ || code === $DQ ||
code === $EQ;
}
// http://www.w3.org/TR/html5/syntax.html#consume-a-character-reference
function isCharRefStart(code: number, extraNotCharRef: number): boolean {
return code != $TAB && code != $LF && code != $FF && code != $SPACE && code != $LT &&
code != $AMPERSAND && code != $EOF && code !== extraNotCharRef;
code === $EQ
}
function isPrefixEnd(code: number): boolean {