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
4c68d107
Commit
4c68d107
authored
Mar 06, 2014
by
Dave Methvin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Event: Call underlying stopImmediatePropagation when present
Fixes #13997 (cherry picked from commit
6a89db86
)
parent
725cdebd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
event.js
src/event.js
+7
-0
event.js
test/unit/event.js
+17
-2
No files found.
src/event.js
View file @
4c68d107
...
@@ -751,7 +751,14 @@ jQuery.Event.prototype = {
...
@@ -751,7 +751,14 @@ jQuery.Event.prototype = {
e
.
cancelBubble
=
true
;
e
.
cancelBubble
=
true
;
},
},
stopImmediatePropagation
:
function
()
{
stopImmediatePropagation
:
function
()
{
var
e
=
this
.
originalEvent
;
this
.
isImmediatePropagationStopped
=
returnTrue
;
this
.
isImmediatePropagationStopped
=
returnTrue
;
if
(
e
&&
e
.
stopImmediatePropagation
)
{
e
.
stopImmediatePropagation
();
}
this
.
stopPropagation
();
this
.
stopPropagation
();
}
}
};
};
...
...
test/unit/event.js
View file @
4c68d107
...
@@ -386,10 +386,13 @@ test("on immediate propagation", function() {
...
@@ -386,10 +386,13 @@ test("on immediate propagation", function() {
$p
.
off
(
"click"
,
"**"
);
$p
.
off
(
"click"
,
"**"
);
});
});
test
(
"on bubbling, isDefaultPrevented"
,
function
()
{
test
(
"on bubbling, isDefaultPrevented
, stopImmediatePropagation
"
,
function
()
{
expect
(
2
);
expect
(
3
);
var
$anchor2
=
jQuery
(
"#anchor2"
),
var
$anchor2
=
jQuery
(
"#anchor2"
),
$main
=
jQuery
(
"#qunit-fixture"
),
$main
=
jQuery
(
"#qunit-fixture"
),
neverCallMe
=
function
()
{
ok
(
false
,
"immediate propagation should have been stopped"
);
},
fakeClick
=
function
(
$jq
)
{
fakeClick
=
function
(
$jq
)
{
// Use a native click so we don't get jQuery simulated bubbling
// Use a native click so we don't get jQuery simulated bubbling
if
(
document
.
createEvent
)
{
if
(
document
.
createEvent
)
{
...
@@ -427,6 +430,18 @@ test("on bubbling, isDefaultPrevented", function() {
...
@@ -427,6 +430,18 @@ test("on bubbling, isDefaultPrevented", function() {
fakeClick
(
$anchor2
);
fakeClick
(
$anchor2
);
$anchor2
.
off
(
"click"
);
$anchor2
.
off
(
"click"
);
$main
.
off
(
"click"
,
"**"
);
$main
.
off
(
"click"
,
"**"
);
if
(
!
window
.
addEventListener
)
{
ok
(
true
,
"Old IE, skipping native stopImmediatePropagation check"
);
}
else
{
$anchor2
.
on
(
"click"
,
function
(
e
)
{
e
.
stopImmediatePropagation
();
ok
(
true
,
"anchor was clicked and prop stopped"
);
});
$anchor2
[
0
].
addEventListener
(
"click"
,
neverCallMe
,
false
);
fakeClick
(
$anchor2
);
$anchor2
[
0
].
removeEventListener
(
"click"
,
neverCallMe
);
}
});
});
test
(
"on(), iframes"
,
function
()
{
test
(
"on(), iframes"
,
function
()
{
...
...
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