Ticket #11912 (closed bug: invalid)
Bug with unwrap?
| Reported by: | chris@… | Owned by: | chris@… |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.7.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
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)
}
Change History
comment:2 Changed 10 months ago by trac-o-bot
- Status changed from pending to closed
- Resolution set to invalid
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!
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Can you provide a test case in jsFiddle? Thanks!