@parse5/tools
Advanced tools
Comparing version 0.0.2-1 to 0.0.2-4
@@ -110,3 +110,3 @@ import { html, Token } from 'parse5'; | ||
*/ | ||
export declare function createElement(tagName: string, namespaceURI?: html.NS, attrs?: Record<string, string> | Token.Attribute[]): Element; | ||
export declare function createElement(tagName: string, namespaceURI?: html.NS | string, attrs?: Record<string, string> | Token.Attribute[]): Element; | ||
/** | ||
@@ -113,0 +113,0 @@ * Sets the text content of the given node |
@@ -171,2 +171,10 @@ import { defaultTreeAdapter, html } from 'parse5'; | ||
} | ||
const namespaceMap = { | ||
HTML: html.NS.HTML, | ||
XML: html.NS.XML, | ||
MATHML: html.NS.MATHML, | ||
SVG: html.NS.SVG, | ||
XLINK: html.NS.XLINK, | ||
XMLNS: html.NS.XMLNS | ||
}; | ||
/** | ||
@@ -181,2 +189,3 @@ * Creates an element node | ||
const normalisedAttrs = []; | ||
const normalisedNamespace = namespaceMap[namespaceURI.toUpperCase()] ?? namespaceURI; | ||
if (Array.isArray(attrs)) { | ||
@@ -197,3 +206,3 @@ for (const attr of attrs) { | ||
} | ||
return defaultTreeAdapter.createElement(tagName, namespaceURI, normalisedAttrs); | ||
return defaultTreeAdapter.createElement(tagName, normalisedNamespace, normalisedAttrs); | ||
} | ||
@@ -200,0 +209,0 @@ /** |
{ | ||
"name": "@parse5/tools", | ||
"version": "0.0.2-1", | ||
"version": "0.0.2-4", | ||
"description": "A small set of utilities for dealing with parse5 syntax trees", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22358
513