Loading ...
Sorry, an error occurred while loading the content.

1142Re: [jslint] no comments before html root element?

Expand Messages
  • Cheney, Edward A SSG RES USAR USARC
    Feb 12, 2010
      Yes, putting anything, except whitespace characters, alters how several browsers perceive rendering of the DOM. This is most noticable in IE with regard to complicated CSS processing, but can be noticed in other browsers under certain circumstances. Here is a good example:


      That code is standards compliant and uses the transitional doctype. It can support up to XHTML 1.0 Strict immediately and XHTML 1.1 with the removal of the "lang" attribute and changing the mime type in both the document head and the HTTP header. The code can be executed locally if an absolute URI is supplied for the CSS source. Put a comment in various strange places into the code and reload it locally to see if the page is rendered differently. Please keep in mind this is simple code containing a few elements and a limited heirarchy. The results are different when the DOM becomes more complicated in either variety and/or heirarchy. I have not tested scripted response to the altered DOM rendering. I would guess, I have not tested this at all, that reading from the DOM would be lesser altered that supplying to the DOM using DOM methods.

      Since comments are nodes in the DOM it only seems logic that they should not exist prior to the root element or after the root's closing element if to be logically referenced in an automated scheme without reliance on an ad hoc approach.

    • Show all 22 messages in this topic