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 }
import type { NodeType } from 'ultrahtml'
type SlotHandler = (string, NodeType) => Promise<Any>
type Replacements = Record<string, string>
export const createForceSetAttributes = (overrideAttributes) => (node) => {
if (!overrideAttributes) return node
const { attributes } = node
if (!attributes) return node
return {...node, attributes: {...attributes, ...overrideAttributes}}
}
......