Modify ↓
Ticket #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: | ||
| Blocking: | Blocked by: |
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
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Fixed in 1.4.