aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJason Moon <jmoon@socialcast.com>2012-05-18 16:30:28 -0400
committerDave Methvin <dave.methvin@gmail.com>2012-05-18 16:34:30 -0400
commite93f2a89e277d3fffbc15b4ef82ebc3ac6a840f5 (patch)
tree4e723f589cb175b44adc07d316e6c7dd21a7f682 /test/unit
parent6bf3f20d4e0f69ab14702152880a0574623490e2 (diff)
downloadjquery-e93f2a89e277d3fffbc15b4ef82ebc3ac6a840f5.tar.gz
jquery-e93f2a89e277d3fffbc15b4ef82ebc3ac6a840f5.zip
Fix #11649. Preserve oldIE submit flag when cloning, closes gh-772.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/event.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/unit/event.js b/test/unit/event.js
index d5582190a..32980cd59 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -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);