#14418 closed bug (notabug)
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: |
Description
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/
Comment nodes are not supported by prepend(). http://api.jquery.com/prepend/#prepend-content-content