769b1bb0 by Adam Heath

Add a function creator that can be used to force-set attributes during

the adjustment phase of Replace.
1 parent 77ef5056
...@@ -9,3 +9,10 @@ export { Children, Custom, Match, Node, Replace } ...@@ -9,3 +9,10 @@ export { Children, Custom, Match, Node, Replace }
9 import type { NodeType } from 'ultrahtml' 9 import type { NodeType } from 'ultrahtml'
10 type SlotHandler = (string, NodeType) => Promise<Any> 10 type SlotHandler = (string, NodeType) => Promise<Any>
11 type Replacements = Record<string, string> 11 type Replacements = Record<string, string>
12
13 export const createForceSetAttributes = (overrideAttributes) => (node) => {
14 if (!overrideAttributes) return node
15 const { attributes } = node
16 if (!attributes) return node
17 return {...node, attributes: {...attributes, ...overrideAttributes}}
18 }
......