Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#14418 closed bug (notabug)

Calling prepend('<!-- comment -->') on an empty table result in an error

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:


Trying to insert some comment inside a <table> element result in: Uncaught TypeError: Cannot read property 'nodeName' of null jquery-1.10.1.js:624 jQuery.extend.nodeName jquery-1.10.1.js:624 manipulationTarget jquery-1.10.1.js:6321 (anonymous function) jquery-1.10.1.js:6079 jQuery.fn.extend.domManip jquery-1.10.1.js:6283 jQuery.fn.extend.prepend jquery-1.10.1.js:6077 (anonymous function) fiddle.jshell.net/agiorgetti/krDfb/2/show/:21 jQuery.event.dispatch jquery-1.10.1.js:5116 jQuery.event.add.elemData.handle

The problem came out when working with jQuery toghether with AngularJs (which uses comments as a placeholder for templates sometimes).

Looking at the code the problem is in the manipulationTarget() function: if the 'content' parameter is not an element nodeName is called with a null (content.firstChild might return null).

here's the jsfiddle with a very simple test case: http://jsfiddle.net/agiorgetti/krDfb/2/

Change History (2)

comment:1 Changed 9 years ago by Rick Waldron

Resolution: notabug
Status: newclosed

Comment nodes are not supported by prepend(). http://api.jquery.com/prepend/#prepend-content-content

comment:2 Changed 9 years ago by gibson042

Also, this is basically a duplicate of #14290.

Note: See TracTickets for help on using tickets.