Opened 16 years ago
Closed 16 years ago
#910 closed bug (fixed)
DOM manipulations with FORM elements fail
Reported by: | Renato | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | core | Version: | 1.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If you execute this snippet of code, you see the form is not appended, only its children
$("form:first").clone(). appendTo("body");
The problem is in the end of jQuery.clean function at line 498:
if ( arg[0] == undefined ) r.push( arg ); else r = jQuery.merge( r, arg );
In fact, the form element can be used as an array to inspect its inputs, so instead of just pushing the form element, jQuery execute the "else" merging the content of the form element and returning its inputs.
Changing to this code, solves the problem:
if ( arg[0] == undefined || jQuery.nodeName(arg,"form") ) r.push( arg ); else r = jQuery.merge( r, arg );
Attachments (4)
Change History (8)
Changed 16 years ago by
Attachment: | new_test.diff added |
---|
comment:1 Changed 16 years ago by
Here is the patch with the test code to be added to the test suite
Index: coreTest.js =================================================================== --- coreTest.js (revisione 1258) +++ coreTest.js (copia locale) @@ -204,7 +204,7 @@ }); test("append(String|Element|Array<Element>|jQuery)", function() { - expect(9); + expect(10); var defaultText = 'Try them out:' var result = $('#first').append('<b>buga</b>'); ok( result.text() == defaultText + 'buga', 'Check if text appending works' ); @@ -233,6 +233,10 @@ ok( $("#sap").append([]), "Check for appending an empty array." ); ok( $("#sap").append(""), "Check for appending an empty string." ); ok( $("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." ); + + reset(); + $("#sap").append(document.getElementById('form')); + ok( $("#sap>form").size() == 1, "Check for appending a form" ); }); test("appendTo(String|Element|Array<Element>|jQuery)", function() { @@ -678,4 +682,4 @@ //console.log( close[0]); // it's the <a> and not a <span> element return false; }).click(); -}); Nessun a-capo alla fine del file +});
comment:2 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in revision 1294.
Thank you for the patch+test.
comment:3 Changed 16 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Reopening because the fix is causing Safari to crash.
comment:4 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Fixed in Revision 1422.
a test for the bug