Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
flushTag() {
if (this.inTag()) {
// [] and [=] tag case
if (this.tagToken[Token.VALUE_ID] === '') {
const value = this.inAttrValue() ? getChar(EQ) : '';
const word = getChar(OPEN_BRAKET) + value + getChar(CLOSE_BRAKET);
this.createWord('', 0, 0);
this.wordToken[Token.VALUE_ID] += word;
this.tagToken = this.dummyToken;
if (this.inAttrValue()) {
this.attrValueToken = this.dummyToken;
}
return;
}
if (this.inAttrName() && !this.inAttrValue()) {
this.tagToken[Token.VALUE_ID] += PLACEHOLDER_SPACE + this.attrNameToken[Token.VALUE_ID];
this.attrNameToken = this.dummyToken;
flushTag() {
if (this.inTag()) {
// [] and [=] tag case
if (this.tagToken[Token.VALUE_ID] === '') {
const value = this.inAttrValue() ? getChar(EQ) : '';
const word = getChar(OPEN_BRAKET) + value + getChar(CLOSE_BRAKET);
this.createWord('', 0, 0);
this.wordToken[Token.VALUE_ID] += word;
this.tagToken = this.dummyToken;
if (this.inAttrValue()) {
this.attrValueToken = this.dummyToken;
}
return;
}
if (this.inAttrName() && !this.inAttrValue()) {
this.tagToken[Token.VALUE_ID] += PLACEHOLDER_SPACE + this.attrNameToken[Token.VALUE_ID];
charWORD(charCode) {
if (this.inTag()) {
if (this.inAttrValue()) {
this.attrValueToken[Token.VALUE_ID] += getChar(charCode);
} else if (this.inAttrName()) {
this.attrNameToken[Token.VALUE_ID] += getChar(charCode);
} else {
this.tagToken[Token.VALUE_ID] += getChar(charCode);
}
} else {
this.createWord();
this.wordToken[Token.VALUE_ID] += getChar(charCode);
}
this.nextCol();
}
flushUnclosedTag() {
if (this.inTag()) {
const value = this.tagToken[Token.VALUE_ID] + (this.attrValueToken && this.attrValueToken[Token.VALUE_ID] ? getChar(EQ) : '');
this.tagToken[Token.TYPE_ID] = Token.TYPE_WORD;
this.tagToken[Token.VALUE_ID] = getChar(OPEN_BRAKET) + value;
this.appendToken(this.tagToken);
this.tagToken = this.dummyToken;
if (this.inAttrValue()) {
this.attrValueToken = this.dummyToken;
}
}
}
charEQ(charCode) {
const nextCharCode = this.seekChar(1);
const isNextQuotemark = nextCharCode === QUOTEMARK;
if (this.inTag()) {
this.attrValueToken = this.createAttrValueToken('');
if (isNextQuotemark) {
this.attrValueToken.quoted = true;
this.skipChar(1);
}
} else {
this.wordToken[Token.VALUE_ID] += getChar(charCode);
}
this.nextCol();
}
charN(charCode) {
this.flushWord();
this.appendToken(this.createNewLineToken(getChar(charCode)));
this.nextLine();
this.colPos = 0;
}
charCLOSEBRAKET(charCode) {
const prevCharCode = this.seekChar(-1);
const isPrevSpace = prevCharCode === SPACE || prevCharCode === TAB;
if (isPrevSpace) {
this.wordToken[Token.VALUE_ID] += getChar(charCode);
}
this.nextCol();
this.flushTag();
this.flushAttrNames();
this.flushAttrs();
}