diff --git a/src/parsers/abstract-template.parser.ts b/src/parsers/abstract-template.parser.ts index ae36faa..f50a083 100644 --- a/src/parsers/abstract-template.parser.ts +++ b/src/parsers/abstract-template.parser.ts @@ -20,4 +20,13 @@ export abstract class AbstractTemplateParser { return ''; } + /** + * Angular's `[attr]="'val'"` syntax is not valid HTML, + * so it can't be parsed by standard HTML parsers. + * This method replaces `[attr]="'val'""` with `attr="val"` + */ + protected _normalizeTemplateAttributes(template: string): string { + return template.replace(/\[([^\]]+)\]="'([^\"]*)'"/g, '$1="$2"'); + } + } diff --git a/src/parsers/directive.parser.ts b/src/parsers/directive.parser.ts index 872481b..9299dce 100644 --- a/src/parsers/directive.parser.ts +++ b/src/parsers/directive.parser.ts @@ -33,13 +33,4 @@ export class DirectiveParser extends AbstractTemplateParser implements ParserInt return results; } - /** - * Angular's `[attr]="'val'"` syntax is not valid HTML, - * so Cheerio is not able to parse it. - * This method replaces `[attr]="'val'""` with `attr="val"` - */ - protected _normalizeTemplateAttributes(template: string): string { - return template.replace(/\[([^\]]+)\]="'([^\"]*)'"/g, '$1="$2"'); - } - }