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