MCPcopy Index your code
hub / github.com/starfederation/datastar / attribute

Function attribute

library/src/engine/engine.ts:66–87  ·  view source on GitHub ↗
(
  plugin: AttributePlugin<R, B>,
)

Source from the content-addressed store, hash-verified

64let datastarReadyDispatched = false
65
66export 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
89export const action = <T>(plugin: ActionPlugin<T>): void => {
90 actionPlugins.set(plugin.name, plugin)

Callers 15

text.tsFile · 0.85
on.tsFile · 0.85
ref.tsFile · 0.85
effect.tsFile · 0.85
computed.tsFile · 0.85
bind.tsFile · 0.85
class.tsFile · 0.85
attr.tsFile · 0.85
onInterval.tsFile · 0.85
onIntersect.tsFile · 0.85
onSignalPatch.tsFile · 0.85
init.tsFile · 0.85

Calls 1

applyQueuedFunction · 0.85

Tested by

no test coverage detected