MCPcopy Index your code
hub / github.com/clips/pattern / attachEvent

Function attachEvent

pattern/canvas.js:21–34  ·  view source on GitHub ↗
(element, name, f)

Source from the content-addressed store, hash-verified

19}
20
21function attachEvent(element, name, f) {
22 /* Cross-browser attachEvent().
23 * Ensures that "this" inside the function f refers to the given element .
24 */
25 f = Function.closure(element, f);
26 if (element.addEventListener) {
27 element.addEventListener(name, f, false);
28 } else if (element.attachEvent) {
29 element.attachEvent("on"+name, f);
30 } else {
31 element["on"+name] = f;
32 }
33 element[name] = f; // So we can do element.name(), see widget().
34}
35
36Function.closure = function(parent, f) {
37 /* Returns the function f, where "this" inside the function refers to the given parent.

Callers 2

canvas.jsFile · 0.70
widgetFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…