Strip out _submit_attached="true". Fixes #11649. #771

Closed
wants to merge 2 commits into
from
View
13 src/manipulation.js
@@ -17,6 +17,7 @@ function createSafeFragment( document ) {
var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
+ rsubmitAttached = /(<form[^>]*)\s_submit_attached="true"/ig,
rleadingWhitespace = /^\s+/,
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
rtagName = /<([\w:]+)/,
@@ -214,9 +215,15 @@ jQuery.fn.extend({
l = this.length;
if ( value === undefined ) {
- return elem.nodeType === 1 ?
- elem.innerHTML.replace( rinlinejQuery, "" ) :
- null;
+ if ( elem.nodeType !== 1 ) {
+ return null;
+ }
+ value = elem.innerHTML.replace( rinlinejQuery, "" );
+ // Bug #11649
+ if ( !jQuery.support.submitBubbles && ~value.indexOf( "_submit_attached=\"true\"" ) ) {
+ value = value.replace( rsubmitAttached, "$1" );
+ }
+ return value;
}
View
10 test/unit/manipulation.js
@@ -547,6 +547,16 @@ test("html5 clone() cannot use the fragment cache in IE (#6485)", function () {
equal( jQuery("aside").length, 2, "clone()ing HTML5 elems does not collapse them" );
});
+test( "html() does not contain _submit_attached=\"true\" attribute (Bug #11649)", function(){
+ expect( 1 );
+
+ jQuery( "#qunit-fixture" ).append( "<form class=\"test_form_11649\"><input name=\"test\"/><input id=\"test_submit_11649\" type=\"submit\"/></form>" ).on( "submit", ".test_form_11649", false );
+ jQuery( "#test_submit_11649" ).click(); // Must trigger a form submission in order to introduce the _submit_attached="true" property on the form
+ jQuery( "#qunit-fixture" ).off( "submit", ".test_form_11649", false );
+
+ equal( jQuery( "#qunit-fixture" ).html().indexOf( "_submit_attached=\"true\"" ), -1, "Check for _submit_attached=\"true\"" );
+});
+
test("html(String) with HTML5 (Bug #6485)", function() {
expect(2);