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
e93f2a89
Commit
e93f2a89
authored
May 18, 2012
by
Jason Moon
Committed by
Dave Methvin
May 18, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #11649. Preserve oldIE submit flag when cloning, closes gh-772.
parent
6bf3f20d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
3 deletions
+37
-3
event.js
src/event.js
+2
-2
manipulation.js
src/manipulation.js
+0
-1
event.js
test/unit/event.js
+35
-0
No files found.
src/event.js
View file @
e93f2a89
...
...
@@ -772,11 +772,11 @@ if ( !jQuery.support.submitBubbles ) {
// Node name check avoids a VML-related crash in IE (#9807)
var
elem
=
e
.
target
,
form
=
jQuery
.
nodeName
(
elem
,
"input"
)
||
jQuery
.
nodeName
(
elem
,
"button"
)
?
elem
.
form
:
undefined
;
if
(
form
&&
!
form
.
_submit_attached
)
{
if
(
form
&&
!
jQuery
.
_data
(
form
,
"_submit_attached"
)
)
{
jQuery
.
event
.
add
(
form
,
"submit._submit"
,
function
(
event
)
{
event
.
_submit_bubble
=
true
;
});
form
.
_submit_attached
=
true
;
jQuery
.
_data
(
form
,
"_submit_attached"
,
true
)
;
}
});
// return undefined since we don't need an event listener
...
...
src/manipulation.js
View file @
e93f2a89
...
...
@@ -467,7 +467,6 @@ function cloneFixAttributes( src, dest ) {
// Clear flags for bubbling special change/submit events, they must
// be reattached when the newly cloned events are first activated
dest
.
removeAttribute
(
"_submit_attached"
);
dest
.
removeAttribute
(
"_change_attached"
);
}
...
...
test/unit/event.js
View file @
e93f2a89
...
...
@@ -1062,6 +1062,41 @@ test("trigger(type, [data], [fn])", function() {
form
.
remove
();
});
test
(
"submit event bubbles on copied forms (#11649)"
,
function
(){
expect
(
3
);
var
$formByClone
,
$formByHTML
,
$testForm
=
jQuery
(
"#testForm"
),
$fixture
=
jQuery
(
"#qunit-fixture"
),
$wrapperDiv
=
jQuery
(
"<div/>"
).
appendTo
(
$fixture
);
function
noSubmit
(
e
)
{
e
.
preventDefault
();
}
function
delegatedSubmit
()
{
ok
(
true
,
"Make sure submit event bubbles up."
);
return
false
;
}
// Attach a delegated submit handler to the parent element
$fixture
.
on
(
"submit"
,
"form"
,
delegatedSubmit
);
// Trigger form submission to introduce the _submit_attached property
$testForm
.
on
(
"submit"
,
noSubmit
).
find
(
"input[name=sub1]"
).
click
();
// Copy the form via .clone() and .html()
$formByClone
=
$testForm
.
clone
(
true
,
true
).
removeAttr
(
"id"
);
$formByHTML
=
jQuery
(
$fixture
.
html
()
).
filter
(
"#testForm"
).
removeAttr
(
"id"
);
$wrapperDiv
.
append
(
$formByClone
,
$formByHTML
);
// Check submit bubbling on the copied forms
$wrapperDiv
.
find
(
"form"
).
on
(
"submit"
,
noSubmit
).
find
(
"input[name=sub1]"
).
click
();
// Clean up
$wrapperDiv
.
remove
();
$fixture
.
off
(
"submit"
,
"form"
,
delegatedSubmit
);
});
test
(
"trigger(eventObject, [data], [fn])"
,
function
()
{
expect
(
28
);
...
...
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