source: node_modules/d3-selection/src/selection/dispatch.js@ e4c61dd

Last change on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 894 bytes
Line 
1import defaultView from "../window.js";
2
3function dispatchEvent(node, type, params) {
4 var window = defaultView(node),
5 event = window.CustomEvent;
6
7 if (typeof event === "function") {
8 event = new event(type, params);
9 } else {
10 event = window.document.createEvent("Event");
11 if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
12 else event.initEvent(type, false, false);
13 }
14
15 node.dispatchEvent(event);
16}
17
18function dispatchConstant(type, params) {
19 return function() {
20 return dispatchEvent(this, type, params);
21 };
22}
23
24function dispatchFunction(type, params) {
25 return function() {
26 return dispatchEvent(this, type, params.apply(this, arguments));
27 };
28}
29
30export default function(type, params) {
31 return this.each((typeof params === "function"
32 ? dispatchFunction
33 : dispatchConstant)(type, params));
34}
Note: See TracBrowser for help on using the repository browser.