Revert "refactor(compiler): use `===` rather than `==` in the ml_parser (#42062)" (#43033)

This reverts commit 28b0c45fde.

PR Close #43033
This commit is contained in:
atscott 2021-08-03 14:48:42 -07:00
parent f85b5f9dbd
commit 28651eb9c1
5 changed files with 15 additions and 15 deletions

View File

@ -54,7 +54,7 @@ export class HtmlTagDefinition implements TagDefinition {
getContentType(prefix?: string): TagContentType {
if (typeof this.contentType === 'object') {
const overrideType = prefix === undefined ? undefined : this.contentType[prefix];
const overrideType = prefix == null ? undefined : this.contentType[prefix];
return overrideType ?? this.contentType.default;
}
return this.contentType;

View File

@ -80,8 +80,8 @@ class _Expander implements html.Visitor {
visitExpansion(icu: html.Expansion, context: any): any {
this.isExpanded = true;
return icu.type === 'plural' ? _expandPluralForm(icu, this.errors) :
_expandDefaultForm(icu, this.errors);
return icu.type == 'plural' ? _expandPluralForm(icu, this.errors) :
_expandDefaultForm(icu, this.errors);
}
visitExpansionCase(icuCase: html.ExpansionCase, context: any): any {
@ -92,7 +92,7 @@ class _Expander implements html.Visitor {
// Plural forms are expanded to `NgPlural` and `NgPluralCase`s
function _expandPluralForm(ast: html.Expansion, errors: ParseError[]): html.Element {
const children = ast.cases.map(c => {
if (PLURAL_CASES.indexOf(c.value) === -1 && !c.value.match(/^=\d+$/)) {
if (PLURAL_CASES.indexOf(c.value) == -1 && !c.value.match(/^=\d+$/)) {
errors.push(new ExpansionError(
c.valueSourceSpan,
`Plural cases should be "=<number>" or one of ${PLURAL_CASES.join(', ')}`));

View File

@ -881,11 +881,11 @@ function isPrefixEnd(code: number): boolean {
}
function isDigitEntityEnd(code: number): boolean {
return code === chars.$SEMICOLON || code === chars.$EOF || !chars.isAsciiHexDigit(code);
return code == chars.$SEMICOLON || code == chars.$EOF || !chars.isAsciiHexDigit(code);
}
function isNamedEntityEnd(code: number): boolean {
return code === chars.$SEMICOLON || code === chars.$EOF || !chars.isAsciiLetter(code);
return code == chars.$SEMICOLON || code == chars.$EOF || !chars.isAsciiLetter(code);
}
function isExpansionCaseStart(peek: number): boolean {
@ -893,7 +893,7 @@ function isExpansionCaseStart(peek: number): boolean {
}
function compareCharCodeCaseInsensitive(code1: number, code2: number): boolean {
return toUpperCaseCharCode(code1) === toUpperCaseCharCode(code2);
return toUpperCaseCharCode(code1) == toUpperCaseCharCode(code2);
}
function toUpperCaseCharCode(code: number): number {
@ -905,9 +905,9 @@ function mergeTextTokens(srcTokens: Token[]): Token[] {
let lastDstToken: Token|undefined = undefined;
for (let i = 0; i < srcTokens.length; i++) {
const token = srcTokens[i];
if ((lastDstToken && lastDstToken.type === TokenType.TEXT && token.type === TokenType.TEXT) ||
(lastDstToken && lastDstToken.type === TokenType.ATTR_VALUE_TEXT &&
token.type === TokenType.ATTR_VALUE_TEXT)) {
if ((lastDstToken && lastDstToken.type == TokenType.TEXT && token.type == TokenType.TEXT) ||
(lastDstToken && lastDstToken.type == TokenType.ATTR_VALUE_TEXT &&
token.type == TokenType.ATTR_VALUE_TEXT)) {
lastDstToken.parts[0]! += token.parts[0];
lastDstToken.sourceSpan.end = token.sourceSpan.end;
} else {

View File

@ -187,7 +187,7 @@ class _TreeBuilder {
if (this._peek.type === TokenType.EXPANSION_CASE_EXP_END) {
if (lastOnStack(expansionFormStack, TokenType.EXPANSION_CASE_EXP_START)) {
expansionFormStack.pop();
if (expansionFormStack.length === 0) return exp;
if (expansionFormStack.length == 0) return exp;
} else {
this.errors.push(
@ -220,9 +220,9 @@ class _TreeBuilder {
const tokens = [token];
const startSpan = token.sourceSpan;
let text = token.parts[0];
if (text.length > 0 && text[0] === '\n') {
if (text.length > 0 && text[0] == '\n') {
const parent = this._getParentElement();
if (parent != null && parent.children.length === 0 &&
if (parent != null && parent.children.length == 0 &&
this.getTagDefinition(parent.name).ignoreFirstLf) {
text = text.substring(1);
tokens[0] = {type: token.type, sourceSpan: token.sourceSpan, parts: [text]} as typeof token;
@ -342,7 +342,7 @@ class _TreeBuilder {
let unexpectedCloseTagDetected = false;
for (let stackIndex = this._elementStack.length - 1; stackIndex >= 0; stackIndex--) {
const el = this._elementStack[stackIndex];
if (el.name === fullName) {
if (el.name == fullName) {
// Record the parse span with the element that is being closed. Any elements that are
// removed from the element stack at this point are closed implicitly, so they won't get
// an end source span (as there is no explicit closing element).

View File

@ -31,7 +31,7 @@ export function splitNsName(elementName: string): [string|null, string] {
const colonIndex = elementName.indexOf(':', 1);
if (colonIndex === -1) {
if (colonIndex == -1) {
throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
}