add hw2
This commit is contained in:
34
node_modules/d3-selection/src/selection/dispatch.js
generated
vendored
Normal file
34
node_modules/d3-selection/src/selection/dispatch.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import defaultView from "../window.js";
|
||||
|
||||
function dispatchEvent(node, type, params) {
|
||||
var window = defaultView(node),
|
||||
event = window.CustomEvent;
|
||||
|
||||
if (typeof event === "function") {
|
||||
event = new event(type, params);
|
||||
} else {
|
||||
event = window.document.createEvent("Event");
|
||||
if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
|
||||
else event.initEvent(type, false, false);
|
||||
}
|
||||
|
||||
node.dispatchEvent(event);
|
||||
}
|
||||
|
||||
function dispatchConstant(type, params) {
|
||||
return function() {
|
||||
return dispatchEvent(this, type, params);
|
||||
};
|
||||
}
|
||||
|
||||
function dispatchFunction(type, params) {
|
||||
return function() {
|
||||
return dispatchEvent(this, type, params.apply(this, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
export default function(type, params) {
|
||||
return this.each((typeof params === "function"
|
||||
? dispatchFunction
|
||||
: dispatchConstant)(type, params));
|
||||
}
|
||||
Reference in New Issue
Block a user