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
4b0c26f0
Commit
4b0c26f0
authored
Apr 05, 2011
by
rwldrn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ticket #8777 undelegate by namespace
parent
2ed81b44
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
8 deletions
+39
-8
event.js
src/event.js
+11
-2
event.js
test/unit/event.js
+28
-6
No files found.
src/event.js
View file @
4b0c26f0
...
@@ -868,10 +868,10 @@ function trigger( type, elem, args ) {
...
@@ -868,10 +868,10 @@ function trigger( type, elem, args ) {
// Create "bubbling" focus and blur events
// Create "bubbling" focus and blur events
if
(
document
.
addEventListener
)
{
if
(
document
.
addEventListener
)
{
jQuery
.
each
({
focus
:
"focusin"
,
blur
:
"focusout"
},
function
(
orig
,
fix
)
{
jQuery
.
each
({
focus
:
"focusin"
,
blur
:
"focusout"
},
function
(
orig
,
fix
)
{
// Attach a single capturing handler while someone wants focusin/focusout
// Attach a single capturing handler while someone wants focusin/focusout
var
attaches
=
0
;
var
attaches
=
0
;
jQuery
.
event
.
special
[
fix
]
=
{
jQuery
.
event
.
special
[
fix
]
=
{
setup
:
function
()
{
setup
:
function
()
{
if
(
attaches
++
===
0
)
{
if
(
attaches
++
===
0
)
{
...
@@ -1027,6 +1027,14 @@ jQuery.each(["live", "die"], function( i, name ) {
...
@@ -1027,6 +1027,14 @@ jQuery.each(["live", "die"], function( i, name ) {
return
this
;
return
this
;
}
}
if
(
name
===
"die"
&&
!
types
&&
origSelector
&&
origSelector
[
0
]
===
"."
)
{
context
.
unbind
(
origSelector
);
return
this
;
}
if
(
jQuery
.
isFunction
(
data
)
)
{
if
(
jQuery
.
isFunction
(
data
)
)
{
fn
=
data
;
fn
=
data
;
data
=
undefined
;
data
=
undefined
;
...
@@ -1184,3 +1192,4 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
...
@@ -1184,3 +1192,4 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
});
});
})(
jQuery
);
})(
jQuery
);
test/unit/event.js
View file @
4b0c26f0
...
@@ -685,7 +685,7 @@ test("hover()", function() {
...
@@ -685,7 +685,7 @@ test("hover()", function() {
test
(
"mouseover triggers mouseenter"
,
function
()
{
test
(
"mouseover triggers mouseenter"
,
function
()
{
expect
(
1
);
expect
(
1
);
var
count
=
0
,
var
count
=
0
,
elem
=
jQuery
(
"<a />"
);
elem
=
jQuery
(
"<a />"
);
elem
.
mouseenter
(
function
()
{
elem
.
mouseenter
(
function
()
{
...
@@ -693,7 +693,7 @@ test("mouseover triggers mouseenter", function() {
...
@@ -693,7 +693,7 @@ test("mouseover triggers mouseenter", function() {
});
});
elem
.
trigger
(
'mouseover'
);
elem
.
trigger
(
'mouseover'
);
equals
(
count
,
1
,
"make sure mouseover triggers a mouseenter"
);
equals
(
count
,
1
,
"make sure mouseover triggers a mouseenter"
);
elem
.
remove
();
elem
.
remove
();
});
});
...
@@ -1956,6 +1956,27 @@ test("delegate with submit", function() {
...
@@ -1956,6 +1956,27 @@ test("delegate with submit", function() {
jQuery
(
document
).
undelegate
();
jQuery
(
document
).
undelegate
();
});
});
test
(
"undelegate() with only namespaces"
,
function
(){
expect
(
2
);
var
$delegate
=
jQuery
(
"#liveHandlerOrder"
),
count
=
0
;
$delegate
.
delegate
(
"a"
,
"click.ns"
,
function
(
e
)
{
count
++
;
});
jQuery
(
"a"
,
$delegate
).
eq
(
0
).
trigger
(
"click.ns"
);
equals
(
count
,
1
,
"delegated click.ns"
);
$delegate
.
undelegate
(
".ns"
);
jQuery
(
"a"
,
$delegate
).
eq
(
1
).
trigger
(
"click.ns"
);
equals
(
count
,
1
,
"no more .ns after undelegate"
);
});
test
(
"Non DOM element events"
,
function
()
{
test
(
"Non DOM element events"
,
function
()
{
expect
(
1
);
expect
(
1
);
...
@@ -1982,8 +2003,8 @@ test("window resize", function() {
...
@@ -1982,8 +2003,8 @@ test("window resize", function() {
test
(
"focusin bubbles"
,
function
()
{
test
(
"focusin bubbles"
,
function
()
{
expect
(
5
);
expect
(
5
);
var
input
=
jQuery
(
'<input type="text" />'
).
prependTo
(
"body"
),
var
input
=
jQuery
(
'<input type="text" />'
).
prependTo
(
"body"
),
order
=
0
;
order
=
0
;
jQuery
(
"body"
).
bind
(
"focusin.focusinBubblesTest"
,
function
(){
jQuery
(
"body"
).
bind
(
"focusin.focusinBubblesTest"
,
function
(){
...
@@ -1996,12 +2017,12 @@ test("focusin bubbles", function() {
...
@@ -1996,12 +2017,12 @@ test("focusin bubbles", function() {
// DOM focus method
// DOM focus method
input
[
0
].
focus
();
input
[
0
].
focus
();
// To make the next focus test work, we need to take focus off the input.
// To make the next focus test work, we need to take focus off the input.
// This will fire another focusin event, so set order to reflect that.
// This will fire another focusin event, so set order to reflect that.
order
=
1
;
order
=
1
;
jQuery
(
"#text1"
)[
0
].
focus
();
jQuery
(
"#text1"
)[
0
].
focus
();
// jQuery trigger, which calls DOM focus
// jQuery trigger, which calls DOM focus
order
=
0
;
order
=
0
;
input
.
trigger
(
"focus"
);
input
.
trigger
(
"focus"
);
...
@@ -2027,3 +2048,4 @@ test("event properties", function() {
...
@@ -2027,3 +2048,4 @@ test("event properties", function() {
}).click();
}).click();
});
});
*/
*/
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