Bug Tracker

Ticket #1296 (closed feature: fixed)

Opened 18 months ago

Last modified 4 weeks ago

new method - innerWrap , does wrap on an elements children

Reported by: wjessup Owned by:
Priority: minor Milestone: 1.2
Component: core Version: 1.1.4
Keywords: Cc:
Needs: Review

Description (last modified by brandon) (diff)

<div>

<span></span> <span></span>

</div>


$('div').innerWrap("<p></p>");

#=>

<div>

<p>

<span></span> <span></span>

</p>

</div>


jquery.js #=> ln 142

//backwards compatibility for wrap

wrap: function(){

return outerWrap();

},

outerWrap: function() {

// The elements to wrap the target around var a = jQuery.clean(arguments);

// Wrap each of the matched elements individually return this.each(function(){

// Clone the structure that we're using to wrap var b = a[0].cloneNode(true);

// Insert it before the element to be wrapped this.parentNode.insertBefore( b, this );

// Find the deepest point in the wrap structure while ( b.firstChild )

b = b.firstChild;

// Move the matched element to within the wrap structure b.appendChild( this );

});

},

innerWrap: function() {

// The elements to wrap the target around var a = jQuery.clean(arguments);

// Wrap each of the matched elements individually return this.each(function(){

// Clone the structure that we're using to wrap var b = a[0].cloneNode(true);

// Insert it before the element to be wrapped var c = $(this).children(); $(this).children().remove(); this.appendChild(b); $(this).children().prepend(c);

});

},

Change History

Changed 18 months ago by brandon

  • priority changed from major to minor
  • type changed from bug to enhancement
  • component changed from ajax to core
  • description modified (diff)

There are several existing innerWrap methods already in use. Here is my recent take on an innerWrap method: http://blog.brandonaaron.net/2007/06/04/jquery-snippets-innerwrap/

Changed 15 months ago by john

  • status changed from new to closed
  • type changed from enhancement to feature
  • version changed from 1.1.2 to 1.1.4
  • resolution set to fixed
  • milestone changed from 1.1.3 to 1.2

Fixed in SVN rev [3021].

Note: See TracTickets for help on using tickets.