Bug Tracker

Modify

Ticket #5142 (closed bug: fixed)

Opened 4 years ago

Last modified 3 years ago

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

comment:1 Changed 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to fixed
  • Component changed from unfiled to manipulation

Fixed in 1.4.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.