Fix for problem in IE 8 where deserialized (then reserialized) form markup was gettin...
authorjeresig <jeresig@gmail.com>
Tue, 2 Feb 2010 02:26:47 +0000 (21:26 -0500)
committerjeresig <jeresig@gmail.com>
Tue, 2 Feb 2010 02:26:47 +0000 (21:26 -0500)
src/manipulation.js
test/unit/manipulation.js

index 543bbcd..2dccc75 100644 (file)
@@ -197,13 +197,15 @@ jQuery.fn.extend({
                                // as properties will not be copied (such as the
                                // the name attribute on an input).
                                var html = this.outerHTML, ownerDocument = this.ownerDocument;
                                // as properties will not be copied (such as the
                                // the name attribute on an input).
                                var html = this.outerHTML, ownerDocument = this.ownerDocument;
-                               if ( !html ) {
+                               if ( !html || jQuery.nodeName( this, "form" ) ) {
                                        var div = ownerDocument.createElement("div");
                                        div.appendChild( this.cloneNode(true) );
                                        html = div.innerHTML;
                                }
 
                                return jQuery.clean([html.replace(rinlinejQuery, "")
                                        var div = ownerDocument.createElement("div");
                                        div.appendChild( this.cloneNode(true) );
                                        html = div.innerHTML;
                                }
 
                                return jQuery.clean([html.replace(rinlinejQuery, "")
+                                       // Handle the case in IE 8 where action=/test/> self-closes a tag
+                                       .replace(/=([^="'>\s]+\/)>/g, '="$1">')
                                        .replace(rleadingWhitespace, "")], ownerDocument)[0];
                        } else {
                                return this.cloneNode(true);
                                        .replace(rleadingWhitespace, "")], ownerDocument)[0];
                        } else {
                                return this.cloneNode(true);
index 168c17c..f921ea1 100644 (file)
@@ -757,7 +757,7 @@ test("replaceAll(String|Element|Array&lt;Element&gt;|jQuery)", function() {
 });
 
 test("clone()", function() {
 });
 
 test("clone()", function() {
-       expect(30);
+       expect(31);
        equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Assert text for #en' );
        var clone = jQuery('#yahoo').clone();
        equals( 'Try them out:Yahoo', jQuery('#first').append(clone).text(), 'Check for clone' );
        equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Assert text for #en' );
        var clone = jQuery('#yahoo').clone();
        equals( 'Try them out:Yahoo', jQuery('#first').append(clone).text(), 'Check for clone' );
@@ -807,6 +807,14 @@ test("clone()", function() {
        div = div.clone(true);
        equals( div.data("a"), true, "Data cloned." );
        equals( div.data("b"), true, "Data cloned." );
        div = div.clone(true);
        equals( div.data("a"), true, "Data cloned." );
        equals( div.data("b"), true, "Data cloned." );
+
+       var form = document.createElement("form");
+       form.action = "/test/";
+       var div = document.createElement("div");
+       div.appendChild( document.createTextNode("test") );
+       form.appendChild( div );
+
+       equals( jQuery(form).clone().children().length, 1, "Make sure we just get the form back." );
 });
 
 if (!isLocal) {
 });
 
 if (!isLocal) {