MCPcopy Create free account
hub / github.com/ampproject/amphtml / dispatch

Function dispatch

third_party/set-dom/original.js:292–307  ·  view source on GitHub ↗

* Recursively trigger an event for a node and it's children. * Only emits events for keyed nodes. * * @param {Node} node - the initial node. * @return {Node}

(node, type)

Source from the content-addressed store, hash-verified

290 * @return {Node}
291 */
292function dispatch (node, type) {
293 // Trigger event for this element if it has a key.
294 if (getKey(node)) {
295 var ev = document.createEvent('Event')
296 var prop = { value: node }
297 ev.initEvent(type, false, false)
298 Object.defineProperty(ev, 'target', prop)
299 Object.defineProperty(ev, 'srcElement', prop)
300 node.dispatchEvent(ev)
301 }
302
303 // Dispatch to all children.
304 var child = node.firstChild
305 while (child) child = dispatch(child, type).nextSibling
306 return node
307}
308
309/**
310 * @private

Callers 2

mountFunction · 0.70
dismountFunction · 0.70

Calls 1

getKeyFunction · 0.70

Tested by

no test coverage detected