Move _normalizeTemplateAttributes to AbstractTemplateParser

This commit is contained in:
Kim Biesbjerg 2016-12-07 06:14:50 +01:00 committed by Kim Biesbjerg
parent 07fa9fc5b1
commit ef574a2d4f
2 changed files with 9 additions and 9 deletions

View File

@ -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"');
}
}

View File

@ -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"');
}
}