Skip to main content

Bug Tracker

Side navigation

#11912 closed bug (invalid)

Opened June 14, 2012 06:21PM UTC

Closed July 18, 2012 08:29AM UTC

Bug with unwrap?

Reported by: chris@teslamedia.co.uk Owned by: chris@teslamedia.co.uk
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description

Was wandering if the following was a bug with the unwrap function or by design?

The following example works fine. Two divs are created, one wraps the other, then unwraps, all while being disconnected, and the outcome is correct. The child div is added and has no parent as it's been unwrapped.

var l1 = $('<div style="background-color:#ff0000;height:20px;width:40px;" />');
var l2 = $('<div style="background-color:#ffff00;height:10px;width:20px;" />');
	   
l2.wrap(l1);
l2.unwrap();	
	      
if(l2.parent().length > 0){	   	   
  $('body').append(l2.parent())
}else{
  $('body').append(l2)   
}
	 

However take into consideration the following example whereby the l2 div is first added and removed from the DOM.

This time the wrap function occurs correctly but the unwrap never seems to occur. Meaning the result is the two divs are added one wrapping the other, even though unwrap has been called.

var l1 = $('<div style="background-color:#ff0000;height:20px;width:40px;" />');
var l2 = $('<div style="background-color:#ffff00;height:10px;width:20px;" />');

$('body').append(l2).contents().remove();
	   
l2.wrap(l1);
l2.unwrap();	
	      
if(l2.parent().length > 0){	   	   
  $('body').append(l2.parent())
}else{
  $('body').append(l2)   
}
	 
Attachments (0)
Change History (2)

Changed July 03, 2012 05:14PM UTC by dmethvin comment:1

owner: → chris@teslamedia.co.uk
status: newpending

Can you provide a test case in jsFiddle? Thanks!

Changed July 18, 2012 08:29AM UTC by trac-o-bot comment:2

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!