Skip to content

Commit

Permalink
fb55#545: Implement handling of simple case w/o additional curly brac…
Browse files Browse the repository at this point in the history
…es and w/o any escaping
  • Loading branch information
alexprey committed Aug 20, 2020
1 parent 5162479 commit e66b0a9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const enum State {
InAttributeValueDq, // "
InAttributeValueSq, // '
InAttributeValueNq,
InAttributeValueCurly, // {

//declarations
BeforeDeclaration, // !
Expand Down Expand Up @@ -250,6 +251,7 @@ export default class Tokenizer {
_cbs: Callbacks;
_xmlMode: boolean;
_decodeEntities: boolean;
_curlyBracesInAttributes: boolean;

constructor(
options: { xmlMode?: boolean; decodeEntities?: boolean, curlyBracesInAttributes?: boolean } | null,
Expand All @@ -258,6 +260,7 @@ export default class Tokenizer {
this._cbs = cbs;
this._xmlMode = !!(options && options.xmlMode);
this._decodeEntities = !!(options && options.decodeEntities);
this._curlyBracesInAttributes = !!(options && options.curlyBracesInAttributes);
}

reset() {
Expand Down Expand Up @@ -416,6 +419,9 @@ export default class Tokenizer {
} else if (c === "'") {
this._state = State.InAttributeValueSq;
this._sectionStart = this._index + 1;
} else if (c === '{') {
this._state = State.InAttributeValueCurly;
this._sectionStart = this._index + 1;
} else if (!whitespace(c)) {
this._state = State.InAttributeValueNq;
this._sectionStart = this._index;
Expand Down Expand Up @@ -446,6 +452,13 @@ export default class Tokenizer {
this._sectionStart = this._index;
}
}
_stateInAttributeValueCurlyBraces(c: string) {
if (c === '}') {
this._emitToken("onattribdata");
this._cbs.onattribend();
this._state = State.BeforeAttributeName;
}
}
_stateInAttributeValueNoQuotes(c: string) {
if (whitespace(c) || c === ">") {
this._emitToken("onattribdata");
Expand Down Expand Up @@ -752,6 +765,8 @@ export default class Tokenizer {
this._stateAfterAttributeName(c);
} else if (this._state === State.InAttributeValueSq) {
this._stateInAttributeValueSingleQuotes(c);
} else if (this._state === State.InAttributeValueCurly) {
this._stateInAttributeValueCurlyBraces(c);
} else if (this._state === State.BeforeAttributeValue) {
this._stateBeforeAttributeValue(c);
} else if (this._state === State.BeforeClosingTagName) {
Expand Down

0 comments on commit e66b0a9

Please sign in to comment.