diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2011-09-26 12:46:01 -0400 |
---|---|---|
committer | Rick Waldron <waldron.rick@gmail.com> | 2011-09-26 12:46:01 -0400 |
commit | 36c82a1bcea14680b7efed47da8f3ebd9bf3de82 (patch) | |
tree | 301559748cb706bdc19ea1abc2a1e5bc52802809 /test/unit/event.js | |
parent | 140bebb739da81e4439663f15e09d7cbbb77bdb8 (diff) | |
parent | c7838c3607239b0231128b270762609703ae3893 (diff) | |
download | jquery-36c82a1bcea14680b7efed47da8f3ebd9bf3de82.tar.gz jquery-36c82a1bcea14680b7efed47da8f3ebd9bf3de82.zip |
Merge branch 'fix-8789-rwldrn-fix' of git://github.com/dmethvin/jquery into fix-8789-rwldrn-fix
* 'fix-8789-rwldrn-fix' of git://github.com/dmethvin/jquery:
Minor cleanups to code. Futile effort to get IE to pass the unit test.
propHooks now an object with `props` array and `filter` function.
Moves mouse properties to mouseProps
current state
Removes early return loop, must copy properties
Shortcircuit fix if possible
More ref localization
Remove unnec. empty line
More reference caching
Cache reference to propHook lookup and result
Restore this.propHooks => jQuery.event.propHooks for better gzip compression. Thanks gnarf
Adds notes re: crash status of fix conditions
Moves key event fixes to own even prop hook defs
jQuery.event.propHooks => this.propHooks where possible
Removes pageX pageY from prop list
Updates rmouseEvent
Implements jQuery.event.propHooks. Fixes #8789
Adds implementation tests for jQuery.event.propHooks #8789
Diffstat (limited to 'test/unit/event.js')
-rw-r--r-- | test/unit/event.js | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/test/unit/event.js b/test/unit/event.js index 9a03bb32c..1ca3e7d78 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -54,7 +54,7 @@ test("Handler changes and .trigger() order", function() { markup.find( "b" ).trigger( "click" ); equals( path, "p div body html ", "Delivered all events" ) - + markup.remove(); }); */ @@ -2332,7 +2332,7 @@ test(".on and .off", function() { // We should have removed all the event handlers ... kinda hacky way to check this var data = jQuery.data[ jQuery( "#onandoff" )[0].expando ] || {}; equals( data.events, undefined, "no events left" ); - + jQuery("#onandoff").remove(); }); @@ -2349,12 +2349,12 @@ test("delegated events quickIs", function() { '</div>' ), str, - check = function(el, expect){ + check = function(el, expect){ str = ""; markup.find( el ).trigger( "blink" ); equals( str, expect, "On " + el ); }, - func = function(e){ + func = function(e){ var tag = this.nodeName.toLowerCase(); str += (str && " ") + tag + "|" + e.handleObj.selector; ok( e.handleObj.quick, "Selector "+ e.handleObj.selector + " on " + tag + " is a quickIs case" ); @@ -2383,6 +2383,37 @@ test("delegated events quickIs", function() { markup.remove(); }); +test("propHooks extensions", function() { + expect( 3 ); + + // IE requires focusable elements to be visible, so append to body + var $fixture = jQuery( "<input type='text' id='hook-fixture' />" ).appendTo( "body" ); + + // Ensure the property doesn't exist + $fixture.bind( "focus", function( event ) { + ok( !("blurrinessLevel" in event), "event.blurrinessLevel does not exist" ); + })[0].focus(); + + // Must blur the link so focus works below + $fixture.unbind( "focus" )[0].blur(); + + // Define a custom property for "focus" events via the filter function + ok( !jQuery.event.propHooks.focus, "We aren't clobbering an existing focus hook" ); + jQuery.event.propHooks.focus = { + filter: function( event, originalEvent ) { + event.blurrinessLevel = 42; + return event; + } + }; + + // Trigger a native focus and ensure the property is set + $fixture.bind( "focus", function( event ) { + equals( event.blurrinessLevel, 42, "event.blurrinessLevel was set" ); + })[0].focus(); + + delete jQuery.event.propHooks.focus; + $fixture.unbind( "focus" ).remove(); +}); (function(){ // This code must be run before DOM ready! @@ -2457,13 +2488,4 @@ test("delegated events quickIs", function() { })(); -/* -test("event properties", function() { - stop(); - jQuery("#simon1").click(function(event) { - ok( event.timeStamp, "assert event.timeStamp is present" ); - start(); - }).click(); -}); -*/ |