Skip to content

Commit

Permalink
Merge branch 't4386' of https://github.com/jitter/jquery into jitter-…
Browse files Browse the repository at this point in the history
…t4386
  • Loading branch information
jeresig committed Dec 6, 2010
2 parents 54a68fa + ab2a70e commit 0276b9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/manipulation.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
// checked="checked" or checked (html5) // checked="checked" or checked (html5)
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
raction = /\=([^="'>\s]+\/)>/g, raction = /\=([^="'>\s]+\/)>/g,
rbodystart = /^\s*<body/i,
rbodyend = /<\/body>\s*$/i,
wrapMap = { wrapMap = {
option: [ 1, "<select multiple='multiple'>", "</select>" ], option: [ 1, "<select multiple='multiple'>", "</select>" ],
legend: [ 1, "<fieldset>", "</fieldset>" ], legend: [ 1, "<fieldset>", "</fieldset>" ],
Expand Down Expand Up @@ -198,11 +200,12 @@ jQuery.fn.extend({
// the name attribute on an input). // the name attribute on an input).
var html = this.outerHTML, var html = this.outerHTML,
ownerDocument = this.ownerDocument; ownerDocument = this.ownerDocument;

if ( !html ) { if ( !html ) {
var div = ownerDocument.createElement("div"); var div = ownerDocument.createElement("div");
div.appendChild( this.cloneNode(true) ); div.appendChild( this.cloneNode(true) );
html = div.innerHTML; html = div.innerHTML;
} else if ( rbodystart.test(html) && rbodyend.test(html) ) {
html = html.replace( rbodystart, "<div>" ).replace( rbodyend, "</div>" );
} }


return jQuery.clean([html.replace(rinlinejQuery, "") return jQuery.clean([html.replace(rinlinejQuery, "")
Expand Down
4 changes: 3 additions & 1 deletion test/unit/manipulation.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ test("replaceAll(String|Element|Array&lt;Element&gt;|jQuery)", function() {
}); });


test("clone()", function() { test("clone()", function() {
expect(31); expect(32);
equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Assert text for #en' ); equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Assert text for #en' );
var clone = jQuery('#yahoo').clone(); var clone = jQuery('#yahoo').clone();
equals( 'Try them out:Yahoo', jQuery('#first').append(clone).text(), 'Check for clone' ); equals( 'Try them out:Yahoo', jQuery('#first').append(clone).text(), 'Check for clone' );
Expand Down Expand Up @@ -872,6 +872,8 @@ test("clone()", function() {
form.appendChild( div ); form.appendChild( div );


equals( jQuery(form).clone().children().length, 1, "Make sure we just get the form back." ); equals( jQuery(form).clone().children().length, 1, "Make sure we just get the form back." );

equal( jQuery("body").clone().children()[0].id, "qunit-header", "Make sure cloning body works" );
}); });


if (!isLocal) { if (!isLocal) {
Expand Down

0 comments on commit 0276b9d

Please sign in to comment.