55 * @typedef {import('hast').Properties } Properties
66 * @typedef {Parent['children'][number]|Root } Node
77 *
8- * @typedef {Properties[string] } PropertyValue Possible property values
9- * @typedef {string|number|boolean } PrimitivePropertyValue Possible primitive HTML attribute values
10- * @typedef {string|[string, ...PrimitivePropertyValue[]] } AttributeValue
11- * @typedef {Object.<string, Array.<PrimitivePropertyValue>> } AttributeMap
8+ * @typedef {Properties[string] } PropertyValue
9+ * Possible property values
10+ * @typedef {string|number|boolean } PrimitivePropertyValue
11+ * Possible primitive HTML attribute values
12+ * @typedef {string|[string, ...Array<PrimitivePropertyValue>] } AttributeValue
13+ * @typedef {Record<string, Array<PrimitivePropertyValue>> } AttributeMap
1214 *
1315 * @typedef Schema Sanitization configuration
14- * @property {Object<string, Array<AttributeValue>> } [attributes] Map of tag names to allowed property names. The special '*' key defines property names allowed on all elements
15- * @property {Object<string, Object<string, PropertyValue>> } [required] Map of tag names to required property names and their default property value
16- * @property {Array.<string> } [tagNames] List of allowed tag names
17- * @property {Object<string, Array.<string>> } [protocols] Map of protocols to allow in property values
18- * @property {Object<string, Array.<string>> } [ancestors] Map of tag names to their required ancestor elements
19- * @property {Array.<string> } [clobber] List of allowed property names which can clobber
20- * @property {string } [clobberPrefix] Prefix to use before potentially clobbering property names
21- * @property {Array.<string> } [strip] Names of elements to strip from the tree
22- * @property {boolean } [allowComments] Whether to allow comments
23- * @property {boolean } [allowDoctypes] Whether to allow doctypes
16+ * @property {Record<string, Array<AttributeValue>> } [attributes]
17+ * Map of tag names to allowed property names. The special '*' key defines property names allowed on all elements
18+ * @property {Record<string, Record<string, PropertyValue>> } [required]
19+ * Map of tag names to required property names and their default property value
20+ * @property {Array<string> } [tagNames]
21+ * List of allowed tag names
22+ * @property {Record<string, Array<string>> } [protocols]
23+ * Map of protocols to allow in property values
24+ * @property {Record<string, Array<string>> } [ancestors]
25+ * Map of tag names to their required ancestor elements
26+ * @property {Array<string> } [clobber]
27+ * List of allowed property names which can clobber
28+ * @property {string } [clobberPrefix]
29+ * Prefix to use before potentially clobbering property names
30+ * @property {Array<string> } [strip]
31+ * Names of elements to strip from the tree
32+ * @property {boolean } [allowComments]
33+ * Whether to allow comments
34+ * @property {boolean } [allowDoctypes]
35+ * Whether to allow doctypes
2436 *
25- * @typedef {(schema: Schema, value: any, node: any, stack: Array. <string>) => unknown } Handler
26- * @typedef {Object. <string, Handler> } NodeDefinition
37+ * @typedef {(schema: Schema, value: any, node: any, stack: Array<string>) => unknown } Handler
38+ * @typedef {Record <string, Handler> } NodeDefinition
2739 * @typedef {((schema: Schema, node: Node) => NodeDefinition|undefined) } NodeDefinitionGetter
28- * @typedef {Object. <string, NodeDefinition|NodeDefinitionGetter> } NodeSchema
40+ * @typedef {Record <string, NodeDefinition|NodeDefinitionGetter> } NodeSchema
2941 */
3042
3143import { defaultSchema } from './schema.js'
@@ -49,8 +61,10 @@ const nodeSchema = {
4961/**
5062 * Utility to sanitize a tree
5163 *
52- * @param {Node } node Hast tree to sanitize
53- * @param {Schema } [schema] Schema defining how to sanitize - defaults to Github style sanitation
64+ * @param {Node } node
65+ * Hast tree to sanitize
66+ * @param {Schema } [schema]
67+ * Schema defining how to sanitize - defaults to Github style sanitation
5468 */
5569export function sanitize ( node , schema ) {
5670 /** @type {Node } */
@@ -85,8 +99,8 @@ export function sanitize(node, schema) {
8599 *
86100 * @param {Schema } schema
87101 * @param {Node } node
88- * @param {Array. <string> } stack
89- * @returns {Node|Array. <Node>|undefined }
102+ * @param {Array<string> } stack
103+ * @returns {Node|Array<Node>|undefined }
90104 */
91105function one ( schema , node , stack ) {
92106 const type = node && node . type
@@ -149,12 +163,12 @@ function one(schema, node, stack) {
149163 * Sanitize `children`.
150164 *
151165 * @type {Handler }
152- * @param {Array. <Node> } children
166+ * @param {Array<Node> } children
153167 * @param {Node } node
154- * @returns {Array. <Node> }
168+ * @returns {Array<Node> }
155169 */
156170function all ( schema , children , node , stack ) {
157- /** @type {Array. <Node> } */
171+ /** @type {Array<Node> } */
158172 const results = [ ]
159173
160174 if ( Array . isArray ( children ) ) {
@@ -222,7 +236,7 @@ function handleProperties(schema, properties, node, stack) {
222236 for ( key in props ) {
223237 if ( own . call ( props , key ) ) {
224238 let value = props [ key ]
225- /** @type {Array. <PrimitivePropertyValue> } */
239+ /** @type {Array<PrimitivePropertyValue> } */
226240 let definition
227241
228242 if ( own . call ( allowed , key ) ) {
@@ -338,14 +352,14 @@ function allow(_, value) {
338352 * Sanitize a property value which is a list.
339353 *
340354 * @param {Schema } schema
341- * @param {Array. <unknown> } values
355+ * @param {Array<unknown> } values
342356 * @param {string } prop
343- * @param {Array. <PrimitivePropertyValue> } definition
344- * @returns {Array. <string|number> }
357+ * @param {Array<PrimitivePropertyValue> } definition
358+ * @returns {Array<string|number> }
345359 */
346360function handlePropertyValues ( schema , values , prop , definition ) {
347361 let index = - 1
348- /** @type {Array. <string|number> } */
362+ /** @type {Array<string|number> } */
349363 const result = [ ]
350364
351365 while ( ++ index < values . length ) {
@@ -366,7 +380,7 @@ function handlePropertyValues(schema, values, prop, definition) {
366380 * @param {Schema } schema
367381 * @param {unknown } value
368382 * @param {string } prop
369- * @param {Array. <PropertyValue> } definition
383+ * @param {Array<PropertyValue> } definition
370384 * @returns {PropertyValue }
371385 */
372386function handlePropertyValue ( schema , value , prop , definition ) {
@@ -431,7 +445,7 @@ function safeProtocol(schema, value, prop) {
431445/**
432446 * Create a map from a list of props or a list of properties and values.
433447 *
434- * @param {Array. <AttributeValue> } values
448+ * @param {Array<AttributeValue> } values
435449 * @returns {AttributeMap }
436450 */
437451function toPropertyValueMap ( values ) {
0 commit comments