* 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)
| 290 | * @return {Node} |
| 291 | */ |
| 292 | function 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 |