Skip to main content

Bug Tracker

Side navigation

#11599 closed bug (invalid)

Opened April 18, 2012 09:06AM UTC

Closed April 19, 2012 01:26AM UTC

before()/insertBefore() breaks node ordering when using a comment node

Reported by: lucas@threeamdesign.com.au Owned by: lucas@threeamdesign.com.au
Priority: low Milestone: None
Component: manipulation Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:
Description

When inserting more than one node before a comment node

the comment node does not stay at the end of the inserted elements in the DOM, it ends up directly after the first inserted node.

$(aCommentNode).before($elsToInsert);//order breaks
$elsToInsert.insertBefore(aCommentNode);//order breaks
//retains correct order
var $comment = $(aCommentNode);
$elsToInsert.each(function() {
  $comment.before(this);
});

Perhaps this affects other non-element nodeTypes as well.

Experienced in Firefox 11 on Win 7.

Attachments (0)
Change History (5)

Changed April 18, 2012 09:19AM UTC by addyosmani comment:1

component: unfiledmanipulation
owner: → lucas@threeamdesign.com.au
priority: undecidedlow
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

Changed April 18, 2012 12:22PM UTC by dmethvin comment:2

Also note that in general, text and comment nodes are not supported in a jQuery collection. There are a few methods like .contents() that obtain them but many jQuery methods will either ignore or remove them.

Changed April 19, 2012 12:23AM UTC by ucavus comment:3

Issue no longer present http://jsfiddle.net/aBW3n/1/

Changed April 19, 2012 12:33AM UTC by ucavus comment:4

Make that never present. It's a bug in Firebug.

Sorry.

Changed April 19, 2012 01:26AM UTC by rwaldron comment:5

resolution: → invalid
status: pendingclosed

Closing per op