It's part of the DOM Level 1 specs, should be supported by all current browsers:
http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createComment You can overwrite it though, document.createComment = null || anything; On Feb 11, 8:20 am, Marc Palmer <wangjamm...@googlemail.com> wrote: > Hi, > > I'm new to jQuery. I had to use 1.3.1 with the HtmlUnit Java web > testing library and we found that with publicly released versions of > HtmlUnit it fails because the JS engine cannot find the function > document.createComment > > Is this a standard DOM method or something "widely supported" by > browsers? > > I looked in the jQuery source, and this is only used once, and only as > part of detection of other bugs: > > (function(){ > // Check to see if the browser returns only elements > // when doing getElementsByTagName("*") > > // Create a fake element > var div = document.createElement("div"); > div.appendChild( document.createComment("") ); > > If there is a possibility that some browsers do not support > createComment then shouldn't that code check first for the existence > of the function? > > Just seems that would be in the proper spirit of jQuery, as I > understand it so far. > > $0.02 > > ~ ~ ~ > Marc Palmer > Blog >http://www.anyware.co.uk > Twitter >http://twitter.com/wangjammer5 > Grails Rocks >http://www.grailsrocks.com