( plugin: AttributePlugin<R, B>, )
| 64 | let datastarReadyDispatched = false |
| 65 | |
| 66 | export const attribute = <R extends Requirement, B extends boolean>( |
| 67 | plugin: AttributePlugin<R, B>, |
| 68 | ): void => { |
| 69 | queuedAttributes.push(plugin as unknown as AttributePlugin) |
| 70 | |
| 71 | if (queuedAttributes.length === 1) { |
| 72 | setTimeout(() => { |
| 73 | for (const attribute of queuedAttributes) { |
| 74 | queuedAttributeNames.add(attribute.name) |
| 75 | attributePlugins.set(attribute.name, attribute) |
| 76 | } |
| 77 | queuedAttributes.length = 0 |
| 78 | const roots = observedRoots.size |
| 79 | ? [...observedRoots] |
| 80 | : [document.documentElement] |
| 81 | for (const root of roots) { |
| 82 | applyQueued(root, !observedRoots.has(root)) |
| 83 | } |
| 84 | queuedAttributeNames.clear() |
| 85 | }) |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | export const action = <T>(plugin: ActionPlugin<T>): void => { |
| 90 | actionPlugins.set(plugin.name, plugin) |
no test coverage detected