[Pkg-javascript-commits] [dojo] 06/28: Fix emit events on 'window' and 'document' objects (cherry picked from commit 3beccffc21fbcd3e21681fc74a29b0c56a31572f)

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 17:39:46 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag 1.8.6
in repository dojo.

commit 3e5df07277665ed9bfce71e400a0443c197f6c69
Author: Eduardo Matos <edu.de.matos at hotmail.com>
Date:   Sat Jul 20 10:05:37 2013 -0300

    Fix emit events on 'window' and 'document' objects
    (cherry picked from commit 3beccffc21fbcd3e21681fc74a29b0c56a31572f)
    
    Conflicts:
    
    	tests/on/on.js
---
 on.js          |  3 ++-
 tests/on/on.js | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/on.js b/on.js
index 72f73f9..c01c1f9 100644
--- a/on.js
+++ b/on.js
@@ -307,7 +307,8 @@ define(["./has!dom-addeventlistener?:./aspect", "./_base/kernel", "./has"], func
 				// that would be a lot of extra code, with little benefit that I can see, seems 
 				// best to use the generic constructor and copy properties over, making it 
 				// easy to have events look like the ones created with specific initializers
-				var nativeEvent = target.ownerDocument.createEvent("HTMLEvents");
+				var ownerDocument = target.ownerDocument || document;
+				var nativeEvent = ownerDocument.createEvent("HTMLEvents");
 				nativeEvent.initEvent(type, !!event.bubbles, !!event.cancelable);
 				// and copy all our properties over
 				for(var i in event){
diff --git a/tests/on/on.js b/tests/on/on.js
index b20bdfd..e1dec89 100644
--- a/tests/on/on.js
+++ b/tests/on/on.js
@@ -129,6 +129,20 @@ doh.register("tests.on",
 			});
 			button.click();
 			signal.remove();
+			signal2.remove();
+
+			// make sure 'document' and 'window' can also emit events
+			var eventEmitted;
+			var globalObjects = [document, window];
+			for(var i = 0, len = globalObjects.length; i < len; i++) {
+				eventEmitted = false;
+				on(globalObjects[i], 'custom-test-event', function () {
+					eventEmitted = true;
+				});
+				on.emit(globalObjects[i], 'custom-test-event', {});
+				t.is(true, eventEmitted);
+			}
+
 			// test out event delegation
 			if(dojo.query){
 				// if dojo.query is loaded, test event delegation

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list