refactor: use instanceof
This commit is contained in:
parent
2507d0cdd2
commit
98b84447c7
@ -44,11 +44,10 @@ export class DirectiveParser implements ParserInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return node.children.reduce((result: TmplAstElement[], childNode: TmplAstNode) => {
|
return node.children.reduce((result: TmplAstElement[], childNode: TmplAstNode) => {
|
||||||
if (this.isElement(childNode)) {
|
if (!this.isElement(childNode)) {
|
||||||
const children = this.findChildrenElements(childNode);
|
return result;
|
||||||
return result.concat(children);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result.concat(this.findChildrenElements(childNode));
|
||||||
}, [node]);
|
}, [node]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,10 +55,8 @@ export class DirectiveParser implements ParserInterface {
|
|||||||
return parseTemplate(template, path).nodes;
|
return parseTemplate(template, path).nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected isElement(node: any): node is TmplAstElement {
|
protected isElement(node: TmplAstNode): node is TmplAstElement {
|
||||||
return node
|
return node instanceof TmplAstElement;
|
||||||
&& node.attributes !== undefined
|
|
||||||
&& node.children !== undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getContents(element: TmplAstElement): string {
|
protected getContents(element: TmplAstElement): string {
|
||||||
|
Loading…
Reference in New Issue
Block a user