Skip to content
Permalink
Browse files

Merge branch 'master' of github.com:jquery/jquery

  • Loading branch information
unknown unknown
unknown authored and unknown committed Dec 8, 2009
2 parents 5778a35 + f5b649f commit fde95fb5ccac0a2c303e4e8049bd3389a51ccd08
Showing with 16 additions and 2 deletions.
  1. +1 −1 src/manipulation.js
  2. +15 −1 test/unit/manipulation.js
@@ -48,7 +48,7 @@ jQuery.fn.extend({

if ( this[0] ) {
// The elements to wrap the target around
var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone();
var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);

if ( this[0].parentNode ) {
wrap.insertBefore( this[0] );
@@ -13,7 +13,7 @@ test("text()", function() {
});

var testWrap = function(val) {
expect(15);
expect(18);
var defaultText = 'Try them out:'
var result = jQuery('#first').wrap(val( '<div class="red"><span></span></div>' )).text();
equals( defaultText, result, 'Check for wrapping of on-the-fly html' );
@@ -54,6 +54,20 @@ var testWrap = function(val) {
equals( j[0].parentNode.parentNode.childNodes.length, 1, "There should only be one element wrapping." );
equals( j.length, 1, "There should only be one element (no cloning)." );
equals( j[0].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph." );

// Wrap an element with a jQuery set
j = jQuery("<span/>").wrap(jQuery("<div></div>"));
equals( j[0].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );

// Wrap an element with a jQuery set and event
result = jQuery("<div></div>").click(function(){
ok(true, "Event triggered.");
});

j = jQuery("<span/>").wrap(result);
equals( j[0].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );

j.parent().trigger("click");
}

test("wrap(String|Element)", function() {

0 comments on commit fde95fb

Please sign in to comment.
You can’t perform that action at this time.