refactor: use instanceof

This commit is contained in:
Kim Biesbjerg 2019-06-19 12:49:09 +02:00
parent 2507d0cdd2
commit 98b84447c7

View File

@ -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 {