diff --git a/packages/angular-html-parser/src/index.ts b/packages/angular-html-parser/src/index.ts index 0dd2c63dc9a91..163c64d29fe43 100644 --- a/packages/angular-html-parser/src/index.ts +++ b/packages/angular-html-parser/src/index.ts @@ -85,3 +85,5 @@ export { ParseSourceFile, } from "../../compiler/src/parse_util.js"; export { getHtmlTagDefinition } from "../../compiler/src/ml_parser/html_tags.js"; +export { htmlAstToRender3Ast } from '../../compiler/src/render3/r3_template_transform.js'; +export { makeBindingParser } from '../../compiler/src/render3/view/template'; diff --git a/packages/compiler/src/i18n/i18n_parser.ts b/packages/compiler/src/i18n/i18n_parser.ts index c5ef54aa94459..62ac8e2fa7246 100644 --- a/packages/compiler/src/i18n/i18n_parser.ts +++ b/packages/compiler/src/i18n/i18n_parser.ts @@ -54,6 +54,11 @@ class _I18nVisitor implements html.Visitor { private _expressionParser: ExpressionParser, private _interpolationConfig: InterpolationConfig) {} + // implements html.Visitor + visit?(node: html.Node, context: any) {} + visitCdata(text: html.CDATA, context: any) {} + visitDocType(docType: html.DocType, context: any) {} + public toI18nMessage( nodes: html.Node[], meaning = '', description = '', customId = '', visitNodeFn: VisitNodeFn|undefined): i18n.Message { diff --git a/packages/compiler/src/ml_parser/html_whitespaces.ts b/packages/compiler/src/ml_parser/html_whitespaces.ts index b6951becfe1ca..e04267b447b16 100644 --- a/packages/compiler/src/ml_parser/html_whitespaces.ts +++ b/packages/compiler/src/ml_parser/html_whitespaces.ts @@ -56,12 +56,12 @@ export class WhitespaceVisitor implements html.Visitor { // but still visit all attributes to eliminate one used as a market to preserve WS return new html.Element( element.name, html.visitAll(this, element.attrs), element.children, element.sourceSpan, - element.startSourceSpan, element.endSourceSpan, element.i18n); + element.startSourceSpan, element.endSourceSpan, null); } return new html.Element( element.name, element.attrs, visitAllWithSiblings(this, element.children), - element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n); + element.sourceSpan, element.startSourceSpan, element.endSourceSpan, null); } visitAttribute(attribute: html.Attribute, context: any): any { @@ -91,7 +91,7 @@ export class WhitespaceVisitor implements html.Visitor { if (isNotBlank) { return new html.CDATA( - replaceNgsp(cdata.value).replace(WS_REPLACE_REGEXP, ' '), cdata.sourceSpan); + replaceNgsp(cdata.value).replace(WS_REPLACE_REGEXP, ' '), cdata.sourceSpan, []); } return null; diff --git a/packages/compiler/src/render3/r3_control_flow.ts b/packages/compiler/src/render3/r3_control_flow.ts index b5960f15baf99..94e84de1ef7e0 100644 --- a/packages/compiler/src/render3/r3_control_flow.ts +++ b/packages/compiler/src/render3/r3_control_flow.ts @@ -163,7 +163,7 @@ export function createSwitchBlock( } if ((node.name !== 'case' || node.parameters.length === 0) && node.name !== 'default') { - unknownBlocks.push(new t.UnknownBlock(node.name, node.sourceSpan, node.nameSpan)); + unknownBlocks.push(new t.UnknownBlock(node.name, node.sourceSpan, node.sourceSpan)); continue; } diff --git a/packages/compiler/src/render3/r3_template_transform.ts b/packages/compiler/src/render3/r3_template_transform.ts index ee43a862ea8e4..ba1f850237187 100644 --- a/packages/compiler/src/render3/r3_template_transform.ts +++ b/packages/compiler/src/render3/r3_template_transform.ts @@ -101,6 +101,11 @@ class HtmlAstToIvyAst implements html.Visitor { constructor(private bindingParser: BindingParser, private options: Render3ParseOptions) {} + // implements html.Visitor + visit?(node: html.Node, context: any) {} + visitCdata(text: html.CDATA, context: any) {} + visitDocType(docType: html.DocType, context: any) {} + // HTML visitor visitElement(element: html.Element): t.Node|null { const isI18nRootElement = isI18nRootNode(element.i18n); @@ -383,7 +388,7 @@ class HtmlAstToIvyAst implements html.Visitor { } result = { - node: new t.UnknownBlock(block.name, block.sourceSpan, block.nameSpan), + node: new t.UnknownBlock(block.name, block.sourceSpan, block.sourceSpan), errors: [new ParseError(block.sourceSpan, errorMessage)], }; break; @@ -618,6 +623,11 @@ class HtmlAstToIvyAst implements html.Visitor { } class NonBindableVisitor implements html.Visitor { + // implements html.Visitor + visit?(node: html.Node, context: any) {} + visitCdata(text: html.CDATA, context: any) {} + visitDocType(docType: html.DocType, context: any) {} + visitElement(ast: html.Element): t.Element|null { const preparsedElement = preparseElement(ast); if (preparsedElement.type === PreparsedElementType.SCRIPT || diff --git a/packages/compiler/src/render3/view/i18n/meta.ts b/packages/compiler/src/render3/view/i18n/meta.ts index f70bb498cd8a8..93504937f23eb 100644 --- a/packages/compiler/src/render3/view/i18n/meta.ts +++ b/packages/compiler/src/render3/view/i18n/meta.ts @@ -55,6 +55,11 @@ export class I18nMetaVisitor implements html.Visitor { private interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG, private keepI18nAttrs = false, private enableI18nLegacyMessageIdFormat = false) {} + // implements html.Visitor + visit?(node: html.Node, context: any) {} + visitCdata(text: html.CDATA, context: any) {} + visitDocType(docType: html.DocType, context: any) {} + private _generateI18nMessage( nodes: html.Node[], meta: string|i18n.I18nMeta = '', visitNodeFn?: VisitNodeFn): i18n.Message {