Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9877ca1

Browse files
committed
1 parent2525cff commit9877ca1

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

‎src/event.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ jQuery.event = {
117117
selector=handleObjIn.selector;
118118
}
119119

120+
// Support objects implementing the EventListener interface.
121+
if(handler&&typeofhandler.handleEvent==="function"){
122+
handler=handler.handleEvent.bind(handler);
123+
}
124+
120125
// Ensure that invalid selectors throw exceptions at attach time
121126
// Evaluate against documentElement in case elem is a non-element node (e.g., document)
122127
if(selector){

‎test/unit/event.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,28 @@ QUnit.test( "on() with non-null,defined data", function( assert ) {
4545

4646
});
4747

48+
QUnit.test("on() with EventListener interface object",function(assert){
49+
50+
assert.expect(4);
51+
52+
varhandler={
53+
eventDelegateData:"can be found",
54+
handleEvent:function(event,data){
55+
assert.equal(data,0,"non-null, defined data (zero) is correctly passed");
56+
assert.equal(this.eventDelegateData,"can be found","event delegate is accessible via this");
57+
}
58+
};
59+
60+
jQuery("#foo").on("foo.on",handler);
61+
jQuery("div").on("foo.delegate","#foo",handler);
62+
63+
jQuery("#foo").trigger("foo",0);
64+
65+
jQuery("#foo").off("foo.on",handler);
66+
jQuery("div").off("foo.delegate","#foo");
67+
68+
});
69+
4870
QUnit.test("Handler changes and .trigger() order",function(assert){
4971
assert.expect(1);
5072

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp