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 { getContentType(prefix?: string): TagContentType {
if (typeof this.contentType === 'object') { 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 overrideType ?? this.contentType.default;
} }
return this.contentType; return this.contentType;

View File

@ -80,7 +80,7 @@ class _Expander implements html.Visitor {
visitExpansion(icu: html.Expansion, context: any): any { visitExpansion(icu: html.Expansion, context: any): any {
this.isExpanded = true; this.isExpanded = true;
return icu.type === 'plural' ? _expandPluralForm(icu, this.errors) : return icu.type == 'plural' ? _expandPluralForm(icu, this.errors) :
_expandDefaultForm(icu, this.errors); _expandDefaultForm(icu, this.errors);
} }
@ -92,7 +92,7 @@ class _Expander implements html.Visitor {
// Plural forms are expanded to `NgPlural` and `NgPluralCase`s // Plural forms are expanded to `NgPlural` and `NgPluralCase`s
function _expandPluralForm(ast: html.Expansion, errors: ParseError[]): html.Element { function _expandPluralForm(ast: html.Expansion, errors: ParseError[]): html.Element {
const children = ast.cases.map(c => { 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( errors.push(new ExpansionError(
c.valueSourceSpan, c.valueSourceSpan,
`Plural cases should be "=<number>" or one of ${PLURAL_CASES.join(', ')}`)); `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 { 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 { 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 { function isExpansionCaseStart(peek: number): boolean {
@ -893,7 +893,7 @@ function isExpansionCaseStart(peek: number): boolean {
} }
function compareCharCodeCaseInsensitive(code1: number, code2: number): boolean { function compareCharCodeCaseInsensitive(code1: number, code2: number): boolean {
return toUpperCaseCharCode(code1) === toUpperCaseCharCode(code2); return toUpperCaseCharCode(code1) == toUpperCaseCharCode(code2);
} }
function toUpperCaseCharCode(code: number): number { function toUpperCaseCharCode(code: number): number {
@ -905,9 +905,9 @@ function mergeTextTokens(srcTokens: Token[]): Token[] {
let lastDstToken: Token|undefined = undefined; let lastDstToken: Token|undefined = undefined;
for (let i = 0; i < srcTokens.length; i++) { for (let i = 0; i < srcTokens.length; i++) {
const token = srcTokens[i]; const token = srcTokens[i];
if ((lastDstToken && lastDstToken.type === TokenType.TEXT && token.type === TokenType.TEXT) || if ((lastDstToken && lastDstToken.type == TokenType.TEXT && token.type == TokenType.TEXT) ||
(lastDstToken && lastDstToken.type === TokenType.ATTR_VALUE_TEXT && (lastDstToken && lastDstToken.type == TokenType.ATTR_VALUE_TEXT &&
token.type === TokenType.ATTR_VALUE_TEXT)) { token.type == TokenType.ATTR_VALUE_TEXT)) {
lastDstToken.parts[0]! += token.parts[0]; lastDstToken.parts[0]! += token.parts[0];
lastDstToken.sourceSpan.end = token.sourceSpan.end; lastDstToken.sourceSpan.end = token.sourceSpan.end;
} else { } else {

View File

@ -187,7 +187,7 @@ class _TreeBuilder {
if (this._peek.type === TokenType.EXPANSION_CASE_EXP_END) { if (this._peek.type === TokenType.EXPANSION_CASE_EXP_END) {
if (lastOnStack(expansionFormStack, TokenType.EXPANSION_CASE_EXP_START)) { if (lastOnStack(expansionFormStack, TokenType.EXPANSION_CASE_EXP_START)) {
expansionFormStack.pop(); expansionFormStack.pop();
if (expansionFormStack.length === 0) return exp; if (expansionFormStack.length == 0) return exp;
} else { } else {
this.errors.push( this.errors.push(
@ -220,9 +220,9 @@ class _TreeBuilder {
const tokens = [token]; const tokens = [token];
const startSpan = token.sourceSpan; const startSpan = token.sourceSpan;
let text = token.parts[0]; let text = token.parts[0];
if (text.length > 0 && text[0] === '\n') { if (text.length > 0 && text[0] == '\n') {
const parent = this._getParentElement(); const parent = this._getParentElement();
if (parent != null && parent.children.length === 0 && if (parent != null && parent.children.length == 0 &&
this.getTagDefinition(parent.name).ignoreFirstLf) { this.getTagDefinition(parent.name).ignoreFirstLf) {
text = text.substring(1); text = text.substring(1);
tokens[0] = {type: token.type, sourceSpan: token.sourceSpan, parts: [text]} as typeof token; tokens[0] = {type: token.type, sourceSpan: token.sourceSpan, parts: [text]} as typeof token;
@ -342,7 +342,7 @@ class _TreeBuilder {
let unexpectedCloseTagDetected = false; let unexpectedCloseTagDetected = false;
for (let stackIndex = this._elementStack.length - 1; stackIndex >= 0; stackIndex--) { for (let stackIndex = this._elementStack.length - 1; stackIndex >= 0; stackIndex--) {
const el = this._elementStack[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 // 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 // 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). // 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); const colonIndex = elementName.indexOf(':', 1);
if (colonIndex === -1) { if (colonIndex == -1) {
throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`); throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
} }