Skip to main content

Bug Tracker

Side navigation

#14418 closed bug (notabug)

Opened October 03, 2013 04:27PM UTC

Closed October 03, 2013 04:49PM UTC

Last modified October 03, 2013 04:53PM UTC

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

Reported by: 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)

jQuery.event.dispatch jquery-1.10.1.js:5116


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:

Attachments (0)
Change History (2)

Changed October 03, 2013 04:49PM UTC by rwaldron comment:1

resolution: → notabug
status: newclosed

Comment nodes are not supported by prepend().

Changed October 03, 2013 04:53PM UTC by gibson042 comment:2

Also, this is basically a duplicate of #14290.