Commit d73ba3f5 authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files

Upstream sync

parent ae8f8b45
......@@ -522,25 +522,13 @@ MochiKit.Base.update(MochiKit.Signal, {
var observers = self._observers;
for (var i = 0; i < observers.length; i++) {
self._disconnect(observers[i]);
}
delete self._observers;
try {
window.onload = undefined;
} catch(e) {
// pass
}
try {
window.onunload = undefined;
} catch(e) {
// pass
if (observers[i][1] !== 'onload' && observers[i][1] !== 'onunload') {
self._disconnect(observers[i]);
}
}
},
_listener: function (src, func, obj, isDOM) {
_listener: function (src, sig, func, obj, isDOM) {
var self = MochiKit.Signal;
var E = self.Event;
if (!isDOM) {
......@@ -548,13 +536,27 @@ MochiKit.Base.update(MochiKit.Signal, {
}
obj = obj || src;
if (typeof(func) == "string") {
return function (nativeEvent) {
obj[func].apply(obj, [new E(src, nativeEvent)]);
};
if (sig === 'onload' || sig === 'onunload') {
return function (nativeEvent) {
obj[func].apply(obj, [new E(src, nativeEvent)]);
MochiKit.Signal.disconnect(src, sig, obj, func);
};
} else {
return function (nativeEvent) {
obj[func].apply(obj, [new E(src, nativeEvent)]);
};
}
} else {
return function (nativeEvent) {
func.apply(obj, [new E(src, nativeEvent)]);
};
if (sig === 'onload' || sig === 'onunload') {
return function (nativeEvent) {
func.apply(obj, [new E(src, nativeEvent)]);
MochiKit.Signal.disconnect(src, sig, func);
};
} else {
return function (nativeEvent) {
func.apply(obj, [new E(src, nativeEvent)]);
};
}
}
},
......@@ -637,7 +639,7 @@ MochiKit.Base.update(MochiKit.Signal, {
sig = "onmouseout";
}
} else {
var listener = self._listener(src, func, obj, isDOM);
var listener = self._listener(src, sig, func, obj, isDOM);
}
if (src.addEventListener) {
......@@ -668,6 +670,7 @@ MochiKit.Base.update(MochiKit.Signal, {
var src = ident[0];
var sig = ident[1];
var listener = ident[2];
if (src.removeEventListener) {
src.removeEventListener(sig.substr(2), listener, false);
} else if (src.detachEvent) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment