Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
b7dd8404
Commit
b7dd8404
authored
Apr 07, 2011
by
Dave Methvin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #8712. Bubble custom events to the window when they are triggered. Ride that, Cowboy!
parent
879be3d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
event.js
src/event.js
+2
-1
event.js
test/unit/event.js
+6
-2
No files found.
src/event.js
View file @
b7dd8404
...
...
@@ -359,7 +359,8 @@ jQuery.event = {
}
}
catch
(
ieError1
)
{}
cur
=
cur
.
parentNode
||
cur
.
ownerDocument
;
// Bubble up to document, then to window
cur
=
cur
.
parentNode
||
cur
.
ownerDocument
||
cur
===
event
.
target
.
ownerDocument
&&
window
;
}
while
(
cur
&&
!
event
.
isPropagationStopped
()
);
// If nobody prevented the default action, do it now
...
...
test/unit/event.js
View file @
b7dd8404
...
...
@@ -779,10 +779,11 @@ test("trigger() shortcuts", function() {
});
test
(
"trigger() bubbling"
,
function
()
{
expect
(
1
4
);
expect
(
1
7
);
var
doc
=
0
,
html
=
0
,
body
=
0
,
main
=
0
,
ap
=
0
;
var
win
=
0
,
doc
=
0
,
html
=
0
,
body
=
0
,
main
=
0
,
ap
=
0
;
jQuery
(
window
).
bind
(
"click"
,
function
(
e
){
win
++
;
});
jQuery
(
document
).
bind
(
"click"
,
function
(
e
){
if
(
e
.
target
!==
document
)
{
doc
++
;
}
});
jQuery
(
"html"
).
bind
(
"click"
,
function
(
e
){
html
++
;
});
jQuery
(
"body"
).
bind
(
"click"
,
function
(
e
){
body
++
;
});
...
...
@@ -790,15 +791,18 @@ test("trigger() bubbling", function() {
jQuery
(
"#ap"
).
bind
(
"click"
,
function
(){
ap
++
;
return
false
;
});
jQuery
(
"html"
).
trigger
(
"click"
);
equals
(
win
,
1
,
"HTML bubble"
);
equals
(
doc
,
1
,
"HTML bubble"
);
equals
(
html
,
1
,
"HTML bubble"
);
jQuery
(
"body"
).
trigger
(
"click"
);
equals
(
win
,
2
,
"Body bubble"
);
equals
(
doc
,
2
,
"Body bubble"
);
equals
(
html
,
2
,
"Body bubble"
);
equals
(
body
,
1
,
"Body bubble"
);
jQuery
(
"#main"
).
trigger
(
"click"
);
equals
(
win
,
3
,
"Main bubble"
);
equals
(
doc
,
3
,
"Main bubble"
);
equals
(
html
,
3
,
"Main bubble"
);
equals
(
body
,
2
,
"Main bubble"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment