Bug Tracker

Opened 10 years ago

Closed 10 years ago

#5142 closed bug (fixed)

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().

Change History (1)

comment:1 Changed 10 years ago by dmethvin

Component: unfiledmanipulation
Resolution: fixed
Status: newclosed

Fixed in 1.4.

Note: See TracTickets for help on using tickets.