refactor(language-service): use strict comparisons (#33114)
PR Close #33114
This commit is contained in:
parent
9e7668f16b
commit
d2222541e8
|
@ -147,7 +147,7 @@ function getAttributeInfosForElement(
|
|||
if (selectors && selectors.length) {
|
||||
// All the attributes that are selectable should be shown.
|
||||
const applicableSelectors =
|
||||
selectors.filter(selector => !selector.element || selector.element == elementName);
|
||||
selectors.filter(selector => !selector.element || selector.element === elementName);
|
||||
const selectorAndAttributeNames =
|
||||
applicableSelectors.map(selector => ({selector, attrs: selector.attrs.filter(a => !!a)}));
|
||||
let attrs = flatten(selectorAndAttributeNames.map<AttrInfo[]>(selectorAndAttr => {
|
||||
|
@ -353,7 +353,7 @@ class ExpressionVisitor extends NullTemplateVisitor {
|
|||
const selectorInfo = getSelectors(this.info);
|
||||
const selectors = selectorInfo.selectors;
|
||||
const selector =
|
||||
selectors.filter(s => s.attrs.some((attr, i) => i % 2 == 0 && attr == key))[0];
|
||||
selectors.filter(s => s.attrs.some((attr, i) => i % 2 === 0 && attr === key))[0];
|
||||
|
||||
const templateBindingResult =
|
||||
this.info.expressionParser.parseTemplateBindings(key, this.attr.value, null, 0);
|
||||
|
@ -370,7 +370,7 @@ class ExpressionVisitor extends NullTemplateVisitor {
|
|||
const keyCompletions = () => {
|
||||
let keys: string[] = [];
|
||||
if (selector) {
|
||||
const attrNames = selector.attrs.filter((_, i) => i % 2 == 0);
|
||||
const attrNames = selector.attrs.filter((_, i) => i % 2 === 0);
|
||||
keys = attrNames.filter(name => name.startsWith(key) && name != key)
|
||||
.map(name => lowerName(name.substr(key.length)));
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ class ExpressionVisitor extends NullTemplateVisitor {
|
|||
});
|
||||
};
|
||||
|
||||
if (!binding || (binding.key == key && !binding.expression)) {
|
||||
if (!binding || (binding.key === key && !binding.expression)) {
|
||||
// We are in the root binding. We should return `let` and keys that are left in the
|
||||
// selector.
|
||||
keyCompletions();
|
||||
|
@ -442,8 +442,8 @@ class ExpressionVisitor extends NullTemplateVisitor {
|
|||
|
||||
private attributeValueCompletions(value: AST, position?: number) {
|
||||
const symbols = getExpressionCompletions(
|
||||
this.getExpressionScope(), value, position == null ? this.attributeValuePosition : position,
|
||||
this.info.template.query);
|
||||
this.getExpressionScope(), value,
|
||||
position === undefined ? this.attributeValuePosition : position, this.info.template.query);
|
||||
if (symbols) {
|
||||
this.result = this.symbolsToCompletions(symbols);
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ function createElementCssSelector(element: Element): CssSelector {
|
|||
if (!attr.name.match(templateAttr)) {
|
||||
const [_, attrNameNoNs] = splitNsName(attr.name);
|
||||
cssSelector.addAttribute(attrNameNoNs, attr.value);
|
||||
if (attr.name.toLowerCase() == 'class') {
|
||||
if (attr.name.toLowerCase() === 'class') {
|
||||
const classes = attr.value.split(/s+/g);
|
||||
classes.forEach(className => cssSelector.addClassName(className));
|
||||
}
|
||||
|
|
|
@ -399,7 +399,7 @@ export class SchemaInformation {
|
|||
}
|
||||
}
|
||||
properties.forEach((property: string) => {
|
||||
if (property == '') {
|
||||
if (property === '') {
|
||||
} else if (property.startsWith('*')) {
|
||||
type[property.substring(1)] = EVENT;
|
||||
} else if (property.startsWith('!')) {
|
||||
|
|
|
@ -60,7 +60,7 @@ export function hasTemplateReference(type: CompileTypeMetadata): boolean {
|
|||
if (type.diDeps) {
|
||||
for (let diDep of type.diDeps) {
|
||||
if (diDep.token && diDep.token.identifier &&
|
||||
identifierName(diDep.token !.identifier !) == 'TemplateRef')
|
||||
identifierName(diDep.token !.identifier !) === 'TemplateRef')
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ export function findTemplateAstAt(
|
|||
// Ignore the host properties of a directive
|
||||
const result = this.visitChildren(context, visit => { visit(ast.inputs); });
|
||||
// We never care about the diretive itself, just its inputs.
|
||||
if (path[path.length - 1] == ast) {
|
||||
if (path[path.length - 1] === ast) {
|
||||
path.pop();
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Reference in New Issue