Permalink
Browse files

passing tests in IE

  • Loading branch information...
tobowers committed Oct 31, 2008
1 parent 5f26233 commit 921b4f1dfdf97fd1338d2b86ae1b43118705a80e
Showing with 28 additions and 16 deletions.
  1. +26 −15 spec/event_handler_spec.js
  2. +2 −1 src/event_handler.js
View
@@ -186,46 +186,57 @@ Screw.Unit(function() {
describe("focus events", function () {
var evtFired;
-
+
it("should fire just like any other event", function () {
- $("no_focus").focus();
+ $("input_el").blur();
evtFired = false;
- MBX.EventHandler.subscribe("#input", "focus", function () { evtFired = true; });
+
+ eventSubscriptions.push(MBX.EventHandler.subscribe("#input_el", "focus", function (evt) { evtFired = true; }));
+
$("input_el").focus();
expect(evtFired).to(be_true);
});
it("should also bubble up", function () {
$("no_focus").focus();
var wrapperEvtFired = false;
- MBX.EventHandler.subscribe(".wrapper", "focus", function () { wrapperEvtFired = true; });
+ eventSubscriptions.push(MBX.EventHandler.subscribe(".wrapper", "focus", function () { wrapperEvtFired = true; }));
$("input_el").focus();
expect(wrapperEvtFired).to(be_true);
- $("no_focus").focus();
});
});
- describe("blur events", function () {
- it("should fire just like any other event", function () {
- var evtFired = false;
- MBX.EventHandler.subscribe("#input", "blur", function () { evtFired = true; });
+ describe("blur events", function () {
+
+ it("should fire just like any other event", function (me) {
+ var evtFired;
$("input_el").focus();
- $("input_el").blur();
- expect(evtFired).to(be_true);
+ evtFired = false;
+
+ var subscription = MBX.EventHandler.subscribe("#input_el", "blur", function () { evtFired = true; });
+
+
+ $("input_el").blur();
+
+ // focusein events in ie seem to not bubble synchronously... so we have to wait here
+ using(me).wait(4).and_then(function () {
+ expect(evtFired).to(be_true);
+ MBX.EventHandler.unsubscribe(subscription);
+ });
+
});
it("should also bubble up", function () {
$("input_el").focus();
var wrapperEvtFired = false;
- MBX.EventHandler.subscribe(".wrapper", "blur", function () { wrapperEvtFired = true; });
+ eventSubscriptions.push(MBX.EventHandler.subscribe(".wrapper", "blur", function () { wrapperEvtFired = true; }));
$("input_el").blur();
expect(wrapperEvtFired).to(be_true);
+
});
});
-
-
describe("deferring functions", function () {
var MyCustomEvent = 0;
var someObj = {};
@@ -288,7 +299,7 @@ Screw.Unit(function() {
expect(MyOtherCustomEvent).to(equal, 1);
using(me).wait(3).and_then(function () {
expect(MyOtherCustomEvent).to(equal, 2);
- })
+ });
});
});
View
@@ -274,14 +274,15 @@ MBX.EventHandler = (function () {
if (!targetElement) {
return;
}
+
opts = opts || {};
var evtType;
if (opts.eventType) {
evtType = opts.eventType;
} else {
evtType = evt.type;
}
-
+
if(targetElement.__MotionboxEventHandlerMaker) {
callFunctionsFromIdOrObject("objects", targetElement.__MotionboxEventHandlerMaker, evtType, evt);
if (!Object.isElement(targetElement)) {

0 comments on commit 921b4f1

Please sign in to comment.