Skip to main content

Bug Tracker

Side navigation

#5142 closed bug (fixed)

Opened August 30, 2009 09:18PM UTC

Closed June 13, 2010 05:23PM UTC

jQuery.fn.after and jQuery.fn.before can break in document fragments

Reported by: brianfreud Owned by:
Priority: major Milestone: 1.4
Component: manipulation Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:
Description

jQuery.fn.after() and jQuery.fn.before() both make the assumption that this has a .parentNode. This is not always the case:

<body>

<div id="foo">

Bar

</div>

</body>

var testVar = $("#div").clone().after('<div>test</div>');

testVar should be expected to now contain $('<div id="foo">Bar</div><div>test</div>'), but because the cloned #div currently existing as a document fragment has no parentNode, you instead get TypeError: this.parentNode is null when attempting the after().

Attachments (0)
Change History (1)

Changed June 13, 2010 05:23PM UTC by dmethvin comment:1

component: unfiledmanipulation
resolution: → fixed
status: newclosed

Fixed in 1.4.