fix(HtmlLexer): tag name must follow "<" without space
see http://www.w3.org/TR/html5/syntax.html#tag-open-state
This commit is contained in:
parent
aecf68117a
commit
47f1d12731
|
@ -378,7 +378,9 @@ class _HtmlTokenizer {
|
||||||
let savedPos = this._savePosition();
|
let savedPos = this._savePosition();
|
||||||
let lowercaseTagName;
|
let lowercaseTagName;
|
||||||
try {
|
try {
|
||||||
this._attemptUntilFn(isNotWhitespace);
|
if (!isAsciiLetter(this.peek)) {
|
||||||
|
throw this._createError(unexpectedCharacterErrorMsg(this.peek), this._getLocation());
|
||||||
|
}
|
||||||
var nameStart = this.index;
|
var nameStart = this.index;
|
||||||
this._consumeTagOpenStart(start);
|
this._consumeTagOpenStart(start);
|
||||||
lowercaseTagName = this.inputLowercase.substring(nameStart, this.index);
|
lowercaseTagName = this.inputLowercase.substring(nameStart, this.index);
|
||||||
|
|
|
@ -174,8 +174,8 @@ export function main() {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow whitespace', () => {
|
it('should allow whitespace after the tag name', () => {
|
||||||
expect(tokenizeAndHumanizeParts('< test >'))
|
expect(tokenizeAndHumanizeParts('<test >'))
|
||||||
.toEqual([
|
.toEqual([
|
||||||
[HtmlTokenType.TAG_OPEN_START, null, 'test'],
|
[HtmlTokenType.TAG_OPEN_START, null, 'test'],
|
||||||
[HtmlTokenType.TAG_OPEN_END],
|
[HtmlTokenType.TAG_OPEN_END],
|
||||||
|
@ -438,6 +438,9 @@ export function main() {
|
||||||
[HtmlTokenType.TAG_CLOSE, '</p>'],
|
[HtmlTokenType.TAG_CLOSE, '</p>'],
|
||||||
[HtmlTokenType.EOF, ''],
|
[HtmlTokenType.EOF, ''],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
expect(tokenizeAndHumanizeParts('< a>'))
|
||||||
|
.toEqual([[HtmlTokenType.TEXT, '< a>'], [HtmlTokenType.EOF]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO(vicb): make the lexer aware of Angular expressions
|
// TODO(vicb): make the lexer aware of Angular expressions
|
||||||
|
|
Loading…
Reference in New Issue