Bug 5312

Summary: comments aren't available via DOM
Product: WebKit Reporter: Scott McDowell <webkit>
Component: DOMAssignee: Timothy Hatcher <timothy>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, blmatthews, gavin.sharp, ian, james
Priority: P2 Keywords: InRadar
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
URL: http://webkit.opendarwin.org/blog/
Bug Depends on:    
Bug Blocks: 9077    
Attachments:
Description Flags
Test Case
none
Turns on comment nodes and fixes a few issues caused by it
none
New version that keeps documentElement const mjs: review+

Description Scott McDowell 2005-10-09 17:48:30 PDT
I was trying out a script that takes the nodeValue out of a comment tag.  Here's
a much simplified version that works in Mozilla, and not in Safari:

<div id="whatanode"><!-- Here I Am --></div>
<script>
x = document.getElementById("whatanode").firstChild;
document.write(x.nodeValue); // should print: Here I Am
</script>

When I view the DOM Tree in Safari, it seems all the comment tags aren't there.
 Are they even in the Webkit DOM?
Comment 1 Scott McDowell 2005-10-09 17:51:30 PDT
Created attachment 4273 [details]
Test Case

In Mozilla, this code prints the string "Here I Am."  In Safari, it fails.
Comment 2 Dave Hyatt 2005-10-09 18:09:58 PDT
They are not included for performance reasons.  We do have a code path that will include the comments, 
but by default we deliberately omit them.
Comment 3 Joost de Valk (AlthA) 2006-02-06 11:46:35 PST
*** Bug 7104 has been marked as a duplicate of this bug. ***
Comment 4 James Brennan 2006-05-24 14:22:55 PDT
Dave, 

It's unclear whether you mean to address this bug or to leave it broken. Please clarify. Thanks!

(In reply to comment #2)
> They are not included for performance reasons.  We do have a code path that
> will include the comments, 
> but by default we deliberately omit them.
> 

Comment 5 Dave Hyatt 2006-05-25 18:22:33 PDT
We intend to fix.  In fact I think we may already have.
Comment 6 David Kilzer (:ddkilzer) 2006-05-29 17:20:53 PDT
(In reply to comment #5)
> We intend to fix.  In fact I think we may already have.

The comment node in the test case (Attachment 4273 [details]) does not appear in the Web Inspector as of WebKit r14619.

See also Bug 9165 (which you may want to change to a duplicate of this bug).
Comment 7 Timothy Hatcher 2006-06-16 09:30:25 PDT
<rdar://problem/4444730>
Comment 8 Timothy Hatcher 2006-07-08 20:54:43 PDT
Created attachment 9281 [details]
Turns on comment nodes and fixes a few issues caused by it
Comment 9 Timothy Hatcher 2006-07-08 21:11:03 PDT
Created attachment 9282 [details]
New version that keeps documentElement const

Uses the mutable keyword on m_documentElement to keep documentElement() a const. This eliminates my earlier const changes.
Comment 10 Maciej Stachowiak 2006-07-09 00:40:59 PDT
Comment on attachment 9282 [details]
New version that keeps documentElement const

r=me
Comment 11 Timothy Hatcher 2006-07-09 00:51:37 PDT
Landed in r15247