Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a701c10

Browse filesBrowse files
petebacondarwindylhunn
authored andcommitted
refactor(compiler): use === rather than == in the ml_parser (#43129)
This is a simple tidy up commit to move to the more specific `===` comparison operator in the HTML lexer/parser. PR Close #43129
1 parent 510931a commit a701c10
Copy full SHA for a701c10

File tree

Expand file treeCollapse file tree

5 files changed

+13
-13
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+13
-13
lines changed

‎packages/compiler/src/ml_parser/html_tags.ts

Copy file name to clipboardExpand all lines: packages/compiler/src/ml_parser/html_tags.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class HtmlTagDefinition implements TagDefinition {
5454

5555
getContentType(prefix?: string): TagContentType {
5656
if (typeof this.contentType === 'object') {
57-
const overrideType = prefix == null ? undefined : this.contentType[prefix];
57+
const overrideType = prefix === undefined ? undefined : this.contentType[prefix];
5858
return overrideType ?? this.contentType.default;
5959
}
6060
return this.contentType;

‎packages/compiler/src/ml_parser/icu_ast_expander.ts

Copy file name to clipboardExpand all lines: packages/compiler/src/ml_parser/icu_ast_expander.ts
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ class _Expander implements html.Visitor {
8080

8181
visitExpansion(icu: html.Expansion, context: any): any {
8282
this.isExpanded = true;
83-
return icu.type == 'plural' ? _expandPluralForm(icu, this.errors) :
84-
_expandDefaultForm(icu, this.errors);
83+
return icu.type === 'plural' ? _expandPluralForm(icu, this.errors) :
84+
_expandDefaultForm(icu, this.errors);
8585
}
8686

8787
visitExpansionCase(icuCase: html.ExpansionCase, context: any): any {
@@ -92,7 +92,7 @@ class _Expander implements html.Visitor {
9292
// Plural forms are expanded to `NgPlural` and `NgPluralCase`s
9393
function _expandPluralForm(ast: html.Expansion, errors: ParseError[]): html.Element {
9494
const children = ast.cases.map(c => {
95-
if (PLURAL_CASES.indexOf(c.value) == -1 && !c.value.match(/^=\d+$/)) {
95+
if (PLURAL_CASES.indexOf(c.value) === -1 && !c.value.match(/^=\d+$/)) {
9696
errors.push(new ExpansionError(
9797
c.valueSourceSpan,
9898
`Plural cases should be "=<number>" or one of ${PLURAL_CASES.join(', ')}`));

‎packages/compiler/src/ml_parser/lexer.ts

Copy file name to clipboardExpand all lines: packages/compiler/src/ml_parser/lexer.ts
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -808,19 +808,19 @@ function isPrefixEnd(code: number): boolean {
808808
}
809809

810810
function isDigitEntityEnd(code: number): boolean {
811-
return code == chars.$SEMICOLON || code == chars.$EOF || !chars.isAsciiHexDigit(code);
811+
return code === chars.$SEMICOLON || code === chars.$EOF || !chars.isAsciiHexDigit(code);
812812
}
813813

814814
function isNamedEntityEnd(code: number): boolean {
815-
return code == chars.$SEMICOLON || code == chars.$EOF || !chars.isAsciiLetter(code);
815+
return code === chars.$SEMICOLON || code === chars.$EOF || !chars.isAsciiLetter(code);
816816
}
817817

818818
function isExpansionCaseStart(peek: number): boolean {
819819
return peek !== chars.$RBRACE;
820820
}
821821

822822
function compareCharCodeCaseInsensitive(code1: number, code2: number): boolean {
823-
return toUpperCaseCharCode(code1) == toUpperCaseCharCode(code2);
823+
return toUpperCaseCharCode(code1) === toUpperCaseCharCode(code2);
824824
}
825825

826826
function toUpperCaseCharCode(code: number): number {
@@ -832,7 +832,7 @@ function mergeTextTokens(srcTokens: Token[]): Token[] {
832832
let lastDstToken: Token|undefined = undefined;
833833
for (let i = 0; i < srcTokens.length; i++) {
834834
const token = srcTokens[i];
835-
if (lastDstToken && lastDstToken.type == TokenType.TEXT && token.type == TokenType.TEXT) {
835+
if (lastDstToken && lastDstToken.type === TokenType.TEXT && token.type === TokenType.TEXT) {
836836
lastDstToken.parts[0]! += token.parts[0];
837837
lastDstToken.sourceSpan.end = token.sourceSpan.end;
838838
} else {

‎packages/compiler/src/ml_parser/parser.ts

Copy file name to clipboardExpand all lines: packages/compiler/src/ml_parser/parser.ts
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class _TreeBuilder {
185185
if (this._peek.type === lex.TokenType.EXPANSION_CASE_EXP_END) {
186186
if (lastOnStack(expansionFormStack, lex.TokenType.EXPANSION_CASE_EXP_START)) {
187187
expansionFormStack.pop();
188-
if (expansionFormStack.length == 0) return exp;
188+
if (expansionFormStack.length === 0) return exp;
189189

190190
} else {
191191
this.errors.push(
@@ -216,9 +216,9 @@ class _TreeBuilder {
216216

217217
private _consumeText(token: lex.Token) {
218218
let text = token.parts[0];
219-
if (text.length > 0 && text[0] == '\n') {
219+
if (text.length > 0 && text[0] === '\n') {
220220
const parent = this._getParentElement();
221-
if (parent != null && parent.children.length == 0 &&
221+
if (parent != null && parent.children.length === 0 &&
222222
this.getTagDefinition(parent.name).ignoreFirstLf) {
223223
text = text.substring(1);
224224
}
@@ -316,7 +316,7 @@ class _TreeBuilder {
316316
let unexpectedCloseTagDetected = false;
317317
for (let stackIndex = this._elementStack.length - 1; stackIndex >= 0; stackIndex--) {
318318
const el = this._elementStack[stackIndex];
319-
if (el.name == fullName) {
319+
if (el.name === fullName) {
320320
// Record the parse span with the element that is being closed. Any elements that are
321321
// removed from the element stack at this point are closed implicitly, so they won't get
322322
// an end source span (as there is no explicit closing element).

‎packages/compiler/src/ml_parser/tags.ts

Copy file name to clipboardExpand all lines: packages/compiler/src/ml_parser/tags.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function splitNsName(elementName: string): [string|null, string] {
3131

3232
const colonIndex = elementName.indexOf(':', 1);
3333

34-
if (colonIndex == -1) {
34+
if (colonIndex === -1) {
3535
throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
3636
}
3737

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.