adjustForeignAttrName (helper/foreign-attr-names.ts)

markuplint · packages/@markuplint/ml-core/src/ml-dom/helper/foreign-attr-names.ts · typescript · MIT
integration, Integration / API

Utility that restores correct case for SVG and MathML attribute names in foreign namespaces.

// Source: https://github.com/markuplint/markuplint | License: MIT | Copyright 2017-2024 Yusuke Hirao
// Provided via justclaw.it.com; keep this notice with the code.
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';

/**
 * The names of SVG attributes that are not all lower case, the second column of the table of
 * "adjust SVG attributes". The HTML parser lower-cases a name it reads and then restores these.
 *
 * @see https://html.spec.whatwg.org/multipage/parsing.html#adjust-svg-attributes
 */
const SVG_ATTR_NAMES = new Map(
	[
		'attributeName',
		'attributeType',
		'baseFrequency',
		'baseProfile',
		'calcMode',
		'clipPathUnits',
		'diffuseConstant',
		'edgeMode',
		'filterUnits',
		'glyphRef',
		'gradientTransform',
		

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key