Add a function creator that can be used to force-set attributes during
the adjustment phase of Replace.
Showing
1 changed file
with
7 additions
and
0 deletions
... | @@ -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 | } | ... | ... |
-
Please register or sign in to post a comment