Skip to content

Commit

Permalink
fix(@angular/build): support valid self-closing MathML tags in HTML i…
Browse files Browse the repository at this point in the history
…ndex file

Prior to this change, the Angular build process incorrectly flagged self-closing MathML tags (e.g., `<msqrt />`) as invalid HTML. This commit rectifies this issue by explicitly allowing self-closing syntax for MathML elements embedded within the HTML index file.
  • Loading branch information
alan-agius4 committed May 23, 2024
1 parent 5f9053a commit c33629e
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
]);

0 comments on commit c33629e

Please sign in to comment.