diff options
author | Jason Bedard <github@jbedard.ca> | 2013-10-31 22:36:38 -0700 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2016-05-04 15:57:25 -0400 |
commit | e61fccb9d736235b4b011f89cba6866bc0b8997d (patch) | |
tree | 96027a74b64d0199a6ea95634c867ea5877c9b99 /test | |
parent | 7f2ebd2c4dea186d7d981b939e6e2983a9d7f9c1 (diff) | |
download | jquery-e61fccb9d736235b4b011f89cba6866bc0b8997d.tar.gz jquery-e61fccb9d736235b4b011f89cba6866bc0b8997d.zip |
Event: Remove fixHooks, propHooks; switch to ES5 getter with addProp
Fixes gh-3103
Fixes gh-1746
Closes gh-2860
- Removes the copy loop in jQuery.event.fix
- Avoids accessing properties such as client/offset/page/screen X/Y
which may cause style recalc or layouts
- Simplifies adding property hooks to event object
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/event.js | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/test/unit/event.js b/test/unit/event.js index 5b00c7c3b..236214730 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2410,36 +2410,28 @@ QUnit.test( "event object properties on natively-triggered event", function( ass $link.off( "click" ).remove(); } ); -QUnit.test( "fixHooks extensions", function( assert ) { +QUnit.test( "addProp extensions", function( assert ) { assert.expect( 2 ); - // IE requires focusable elements to be visible, so append to body - var $fixture = jQuery( "<input type='text' id='hook-fixture' />" ).appendTo( "body" ), - saved = jQuery.event.fixHooks.click; + var $fixture = jQuery( "<div>" ).appendTo( "#qunit-fixture" ); // Ensure the property doesn't exist $fixture.on( "click", function( event ) { - assert.ok( !( "blurrinessLevel" in event ), "event.blurrinessLevel does not exist" ); + assert.ok( !( "testProperty" in event ), "event.testProperty does not exist" ); } ); fireNative( $fixture[ 0 ], "click" ); $fixture.off( "click" ); - jQuery.event.fixHooks.click = { - filter: function( event ) { - event.blurrinessLevel = 42; - return event; - } - }; + jQuery.event.addProp( "testProperty", function() { return 42; } ); // Trigger a native click and ensure the property is set $fixture.on( "click", function( event ) { - assert.equal( event.blurrinessLevel, 42, "event.blurrinessLevel was set" ); + assert.equal( event.testProperty, 42, "event.testProperty getter was invoked" ); } ); fireNative( $fixture[ 0 ], "click" ); + $fixture.off( "click" ); - delete jQuery.event.fixHooks.click; - $fixture.off( "click" ).remove(); - jQuery.event.fixHooks.click = saved; + $fixture.remove(); } ); QUnit.test( "drag/drop events copy mouse-related event properties (gh-1925, gh-2009)", function( assert ) { |