From 83360f302a5b89f30324554dd86cf3ff07cd5184 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 23 May 2024 15:43:37 +0000 Subject: [PATCH 1/2] fix(@angular/build): support valid self-closing SVG tags in HTML index file Prior to this change, the Angular build process incorrectly flagged self-closing SVG tags (e.g., ``) as invalid HTML. This commit rectifies this issue by explicitly allowing self-closing syntax for SVG elements embedded within the HTML index file. Closes: #27702 --- .../utils/index-file/augment-index-html.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/angular/build/src/utils/index-file/augment-index-html.ts b/packages/angular/build/src/utils/index-file/augment-index-html.ts index 4c9f5fe16918..a52c5425eda7 100644 --- a/packages/angular/build/src/utils/index-file/augment-index-html.ts +++ b/packages/angular/build/src/utils/index-file/augment-index-html.ts @@ -65,6 +65,29 @@ const VALID_SELF_CLOSING_TAGS = new Set([ 'source', 'track', 'wbr', + /** SVG tags */ + 'circle', + 'ellipse', + 'line', + 'path', + 'polygon', + 'polyline', + 'rect', + 'text', + 'tspan', + 'linearGradient', + 'radialGradient', + 'stop', + 'image', + 'pattern', + 'defs', + 'g', + 'marker', + 'mask', + 'style', + 'symbol', + 'use', + 'view', ]); /* From 1db1d4b7afd5edc1b065ad1ede9d72eb3a4f37f3 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 23 May 2024 15:55:25 +0000 Subject: [PATCH 2/2] fix(@angular/build): support valid self-closing MathML tags in HTML index file Prior to this change, the Angular build process incorrectly flagged self-closing MathML tags (e.g., ``) as invalid HTML. This commit rectifies this issue by explicitly allowing self-closing syntax for MathML elements embedded within the HTML index file. --- .../utils/index-file/augment-index-html.ts | 42 +------------ .../index-file/valid-self-closing-tags.ts | 59 +++++++++++++++++++ 2 files changed, 60 insertions(+), 41 deletions(-) create mode 100644 packages/angular/build/src/utils/index-file/valid-self-closing-tags.ts diff --git a/packages/angular/build/src/utils/index-file/augment-index-html.ts b/packages/angular/build/src/utils/index-file/augment-index-html.ts index a52c5425eda7..4c44e671daf6 100644 --- a/packages/angular/build/src/utils/index-file/augment-index-html.ts +++ b/packages/angular/build/src/utils/index-file/augment-index-html.ts @@ -10,6 +10,7 @@ import { createHash } from 'node:crypto'; import { extname } from 'node:path'; import { loadEsmModule } from '../load-esm'; import { htmlRewritingStream } from './html-rewriting-stream'; +import { VALID_SELF_CLOSING_TAGS } from './valid-self-closing-tags'; export type LoadOutputFileFunctionType = (file: string) => Promise; @@ -49,47 +50,6 @@ export interface FileInfo { extension: string; } -/** A list of valid self closing HTML elements */ -const VALID_SELF_CLOSING_TAGS = new Set([ - 'area', - 'base', - 'br', - 'col', - 'embed', - 'hr', - 'img', - 'input', - 'link', - 'meta', - 'param', - 'source', - 'track', - 'wbr', - /** SVG tags */ - 'circle', - 'ellipse', - 'line', - 'path', - 'polygon', - 'polyline', - 'rect', - 'text', - 'tspan', - 'linearGradient', - 'radialGradient', - 'stop', - 'image', - 'pattern', - 'defs', - 'g', - 'marker', - 'mask', - 'style', - 'symbol', - 'use', - 'view', -]); - /* * Helper function used by the IndexHtmlWebpackPlugin. * Can also be directly used by builder, e. g. in order to generate an index.html diff --git a/packages/angular/build/src/utils/index-file/valid-self-closing-tags.ts b/packages/angular/build/src/utils/index-file/valid-self-closing-tags.ts new file mode 100644 index 000000000000..9970404a6342 --- /dev/null +++ b/packages/angular/build/src/utils/index-file/valid-self-closing-tags.ts @@ -0,0 +1,59 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +/** A list of valid self closing HTML elements */ +export const VALID_SELF_CLOSING_TAGS = new Set([ + 'area', + 'base', + 'br', + 'col', + 'embed', + 'hr', + 'img', + 'input', + 'link', + 'meta', + 'param', + 'source', + 'track', + 'wbr', + /** SVG tags */ + 'circle', + 'ellipse', + 'line', + 'path', + 'polygon', + 'polyline', + 'rect', + 'text', + 'tspan', + 'linearGradient', + 'radialGradient', + 'stop', + 'image', + 'pattern', + 'defs', + 'g', + 'marker', + 'mask', + 'style', + 'symbol', + 'use', + 'view', + /** MathML tags */ + 'mspace', + 'mphantom', + 'mrow', + 'mfrac', + 'msqrt', + 'mroot', + 'mstyle', + 'merror', + 'mpadded', + 'mtable', +]);