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
14b09ef9
Commit
14b09ef9
authored
Apr 07, 2013
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ref #12652: Allow overriding native .click() suppression
parent
e3777b64
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
32 deletions
+36
-32
event.js
src/event.js
+16
-11
event.js
test/unit/event.js
+20
-21
No files found.
src/event.js
View file @
14b09ef9
...
@@ -308,8 +308,8 @@ jQuery.event = {
...
@@ -308,8 +308,8 @@ jQuery.event = {
// If nobody prevented the default action, do it now
// If nobody prevented the default action, do it now
if
(
!
onlyHandlers
&&
!
event
.
isDefaultPrevented
()
)
{
if
(
!
onlyHandlers
&&
!
event
.
isDefaultPrevented
()
)
{
if
(
(
!
special
.
_default
||
special
.
_default
.
apply
(
e
lem
.
ownerDocument
,
data
)
===
false
)
&&
if
(
(
!
special
.
_default
||
special
.
_default
.
apply
(
e
ventPath
.
pop
()
,
data
)
===
false
)
&&
!
(
type
===
"click"
&&
jQuery
.
nodeName
(
elem
,
"a"
))
&&
jQuery
.
acceptData
(
elem
)
)
{
jQuery
.
acceptData
(
elem
)
)
{
// Call a native DOM method on the target with the same name name as the event.
// Call a native DOM method on the target with the same name name as the event.
// Can't use an .isFunction() check here because IE6/7 fails that test.
// Can't use an .isFunction() check here because IE6/7 fails that test.
...
@@ -552,15 +552,6 @@ jQuery.event = {
...
@@ -552,15 +552,6 @@ jQuery.event = {
// Prevent triggered image.load events from bubbling to window.load
// Prevent triggered image.load events from bubbling to window.load
noBubble
:
true
noBubble
:
true
},
},
click
:
{
// For checkbox, fire native event so checked state will be right
trigger
:
function
()
{
if
(
jQuery
.
nodeName
(
this
,
"input"
)
&&
this
.
type
===
"checkbox"
&&
this
.
click
)
{
this
.
click
();
return
false
;
}
}
},
focus
:
{
focus
:
{
// Fire native event if possible so blur/focus sequence is correct
// Fire native event if possible so blur/focus sequence is correct
trigger
:
function
()
{
trigger
:
function
()
{
...
@@ -586,6 +577,20 @@ jQuery.event = {
...
@@ -586,6 +577,20 @@ jQuery.event = {
},
},
delegateType
:
"focusout"
delegateType
:
"focusout"
},
},
click
:
{
// For checkbox, fire native event so checked state will be right
trigger
:
function
()
{
if
(
jQuery
.
nodeName
(
this
,
"input"
)
&&
this
.
type
===
"checkbox"
&&
this
.
click
)
{
this
.
click
();
return
false
;
}
},
// For cross-browser consistency, don't fire native .click() on links
_default
:
function
(
event
)
{
return
jQuery
.
nodeName
(
event
.
target
,
"a"
);
}
},
beforeunload
:
{
beforeunload
:
{
postDispatch
:
function
(
event
)
{
postDispatch
:
function
(
event
)
{
...
...
test/unit/event.js
View file @
14b09ef9
...
@@ -177,58 +177,57 @@ test("on(), multiple events at once and namespaces", function() {
...
@@ -177,58 +177,57 @@ test("on(), multiple events at once and namespaces", function() {
test
(
"on(), namespace with special add"
,
function
()
{
test
(
"on(), namespace with special add"
,
function
()
{
expect
(
27
);
expect
(
27
);
var
div
=
jQuery
(
"<div/>"
).
on
(
"test"
,
function
(
e
)
{
var
i
=
0
,
ok
(
true
,
"Test event fired."
);
div
=
jQuery
(
"<div/>"
).
appendTo
(
"#qunit-fixture"
).
on
(
"test"
,
function
(
e
)
{
});
ok
(
true
,
"Test event fired."
);
});
var
i
=
0
;
jQuery
.
event
.
special
[
"test"
]
=
{
jQuery
.
event
.
special
[
"test"
]
=
{
_default
:
function
(
e
,
data
)
{
_default
:
function
(
e
,
data
)
{
equal
(
this
,
document
,
"Make sure we're at the top of the chain
."
);
equal
(
e
.
type
,
"test"
,
"Make sure we're dealing with a test event
."
);
equal
(
e
.
type
,
"test"
,
"And that we're still dealing with a test event
."
);
ok
(
data
,
"And that trigger data was passed
."
);
e
qual
(
e
.
target
,
div
[
0
],
"And that the target is correct."
);
strictE
qual
(
e
.
target
,
div
[
0
],
"And that the target is correct."
);
ok
(
data
!==
undefined
,
"And that trigger data was passed
."
);
equal
(
this
,
window
,
"And that the context is correct
."
);
},
},
setup
:
function
(){},
setup
:
function
()
{},
teardown
:
function
(){
teardown
:
function
()
{
ok
(
true
,
"Teardown called."
);
ok
(
true
,
"Teardown called."
);
},
},
add
:
function
(
handleObj
)
{
add
:
function
(
handleObj
)
{
var
handler
=
handleObj
.
handler
;
var
handler
=
handleObj
.
handler
;
handleObj
.
handler
=
function
(
e
)
{
handleObj
.
handler
=
function
(
e
)
{
e
.
xyz
=
++
i
;
e
.
xyz
=
++
i
;
handler
.
apply
(
this
,
arguments
);
handler
.
apply
(
this
,
arguments
);
};
};
},
},
remove
:
function
()
{
remove
:
function
()
{
ok
(
true
,
"Remove called."
);
ok
(
true
,
"Remove called."
);
}
}
};
};
div
.
on
(
"test.a"
,
{
"x"
:
1
},
function
(
e
)
{
div
.
on
(
"test.a"
,
{
x
:
1
},
function
(
e
)
{
ok
(
!!
e
.
xyz
,
"Make sure that the data is getting passed through."
);
ok
(
!!
e
.
xyz
,
"Make sure that the data is getting passed through."
);
equal
(
e
.
data
[
"x"
],
1
,
"Make sure data is attached properly."
);
equal
(
e
.
data
[
"x"
],
1
,
"Make sure data is attached properly."
);
});
});
div
.
on
(
"test.b"
,
{
"x"
:
2
},
function
(
e
)
{
div
.
on
(
"test.b"
,
{
x
:
2
},
function
(
e
)
{
ok
(
!!
e
.
xyz
,
"Make sure that the data is getting passed through."
);
ok
(
!!
e
.
xyz
,
"Make sure that the data is getting passed through."
);
equal
(
e
.
data
[
"x"
],
2
,
"Make sure data is attached properly."
);
equal
(
e
.
data
[
"x"
],
2
,
"Make sure data is attached properly."
);
});
});
// Should trigger 5
// Should trigger 5
div
.
trigger
(
"test"
,
33.33
);
div
.
trigger
(
"test"
,
33.33
);
// Should trigger 2
// Should trigger 2
div
.
trigger
(
"test.a"
,
"George Harrison"
);
div
.
trigger
(
"test.a"
,
"George Harrison"
);
// Should trigger 2
// Should trigger 2
div
.
trigger
(
"test.b"
,
{
year
:
1982
}
);
div
.
trigger
(
"test.b"
,
{
year
:
1982
}
);
// Should trigger 4
// Should trigger 4
div
.
off
(
"test"
);
div
.
off
(
"test"
);
div
=
jQuery
(
"<div/>"
).
on
(
"test"
,
function
(
e
)
{
div
=
jQuery
(
"<div/>"
).
on
(
"test"
,
function
(
e
)
{
ok
(
true
,
"Test event fired."
);
ok
(
true
,
"Test event fired."
);
});
});
...
...
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