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

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

Expand Messages
  • Cheney, Edward A SSG RES USAR USARC
    HTML is not XML and is processed as XML less than .0001% of the time across the web. As such your comments regarding XML are irrelevant. Nowhere does the
    Message 1 of 22 , Feb 9, 2010
    • 0 Attachment
      HTML is not XML and is processed as XML less than .0001% of the time across the web. As such your comments regarding XML are irrelevant. Nowhere does the JSLint tool to claim to support or process XML in any form. Furthermore it is very bad practice to include comments prior to the initial XML processing declarations as this can quite likely interfere with XML processing when vocabularies from multiple separate definitions are included in a single XML instance. It is my recommendation that comments should not come before any XML processing declaration since the XML processing declarations always go at the top of the document.

      It is not valid to include comments prior to the doctype declaration in a HTML 4 or XHTML1.x document. The specifications say nothing to this effect, but it should be presumed that processing declarations must be first explicitly in an HTML document, or in the case of XHTML the XML processing declarations must precede the SGML processing declarations. Failure to comply results in altered rendering of the DOM in various different browsers, where such an alteration is contrary to standards compliance and cross browser conformity. In IE this phenomenon is defined as quirks mode and while most obvious to IE other browsers exhibit such behaviors less dramatically. As a result never include comments prior to the doctype. Compare the implications of such violations in your own testing.

      Furthermore, it is bad practice to rely upon a source that may or may not differ from the language of the technologies' conformance specifications except where rules of best practice are concerned in the absence of specifics or conflict to standards language.

      Finally, browsers are sloppy. Everything in HTML processing is acceptable until its not, but that has absolutely no bearing on validity. That is why there are standards. Please do not confuse acceptability for validity.

      Austin
    • Mark Volkmann
      On Tue, Feb 9, 2010 at 1:02 PM, Cheney, Edward A SSG RES USAR USARC
      Message 2 of 22 , Feb 9, 2010
      • 0 Attachment
        On Tue, Feb 9, 2010 at 1:02 PM, Cheney, Edward A SSG RES USAR USARC <
        austin.cheney@...> wrote:

        >
        >
        HTML is not XML
        >

        Right. But XHTML is an that's what I happen to be using. I was hoping that
        JSLint could support my use of XHTML.


        > and is processed as XML less than .0001% of the time across the web. As
        > such your comments regarding XML are irrelevant. Nowhere does the JSLint
        > tool to claim to support or process XML in any form. Furthermore it is very
        > bad practice to include comments prior to the initial XML processing
        > declarations as this can quite likely interfere with XML processing when
        > vocabularies from multiple separate definitions are included in a single XML
        > instance. It is my recommendation that comments should not come before any
        > XML processing declaration since the XML processing declarations always go
        > at the top of the document.
        >

        Right. The XML recommendation doesn't allow comments before the XML
        declaration (not technically considered a processing instruction), but they
        are allowed before processing instructions that appear in the prolog.

        > It is not valid to include comments prior to the doctype declaration in a
        > HTML 4 or XHTML1.x document. The specifications say nothing to this effect,
        > but it should be presumed that processing declarations must be first
        > explicitly in an HTML document, or in the case of XHTML the XML processing
        > declarations must precede the SGML processing declarations.
        >
        I think you are considering the XML declaration to be a kind of processing
        instruction, but it isn't. You are correct that comments cannot proceed the
        XML declaration.

        > Failure to comply results in altered rendering of the DOM in various
        > different browsers, where such an alteration is contrary to standards
        > compliance and cross browser conformity. In IE this phenomenon is defined as
        > quirks mode and while most obvious to IE other browsers exhibit such
        > behaviors less dramatically. As a result never include comments prior to the
        > doctype. Compare the implications of such violations in your own testing.
        >
        What if you don't have a DOCTYPE? JSLint doesn't allow comments before the
        root element html even if there is no DOCTYPE.

        > Furthermore, it is bad practice to rely upon a source that may or may not
        > differ from the language of the technologies' conformance specifications
        > except where rules of best practice are concerned in the absence of
        > specifics or conflict to standards language.
        >
        > Finally, browsers are sloppy. Everything in HTML processing is acceptable
        > until its not, but that has absolutely no bearing on validity. That is why
        > there are standards. Please do not confuse acceptability for validity.
        >
        > Austin
        >
        It seems that JSLint could be modified to allow comments that come after an
        XML declaration (if one is present) and perhaps after a DOCTYPE (if one is
        present), but before the html tag. Are you saying that doing so causes
        problems for a particular web browser?

        --
        R. Mark Volkmann
        Object Computing, Inc.


        [Non-text portions of this message have been removed]
      • Cheney, Edward A SSG RES USAR USARC
        Any tag that is delimited as
        Message 3 of 22 , Feb 9, 2010
        • 0 Attachment
          Any tag that is delimited as <?xml is an XML processing declaration. Several such declarations may occur in an XML document and preceed schema validation.

          > What if you don't have a DOCTYPE?
          The default rendering is quirks mode and user agents do the best they can to guess at the rendering model and DOM, but that guessing opens wild variance that defeats cross browser conformity. Absense of a doctype destroys standards compliance back until HTML 2, which predates the standardized specification of the DOM. In accordance with the standards the doctype declaration is required since HTML 3 and HTML 3.2.

          > JSLint doesn't allow comments before the root element html even if there is no DOCTYPE.
          JSLint is enforcing a good practice. I urge you to follow it.

          Why would you want to suggest a change to JSLint in favor of a practice that exposes considerable costs and risks to management of HTML documents?

          Austin
        • Mark Volkmann
          On Tue, Feb 9, 2010 at 11:23 PM, Cheney, Edward A SSG RES USAR USARC ... Maybe I can learn something new here. Can you point me to a description of the term
          Message 4 of 22 , Feb 10, 2010
          • 0 Attachment
            On Tue, Feb 9, 2010 at 11:23 PM, Cheney, Edward A SSG RES USAR USARC
            <austin.cheney@...> wrote:
            >
            >
            >
            > Any tag that is delimited as <?xml is an XML processing declaration. Several such declarations may occur in an XML document and preceed schema validation.

            Maybe I can learn something new here. Can you point me to a
            description of the term "XML processing declaration"? It is my
            understanding that there are "XML declarations" and "processing
            instructions" and that an "XML declaration" is not considered to be a
            kind of "processing instruction" even though they have the same
            syntax. There are two reasons why I think this distinction is
            important. First, when the DOM Document getProcessingInstructions
            method is called, it will not return the XML declaration. Second, the
            recommendation says that comments cannot proceed the XML declaration,
            but can proceed processing instructions.
            I understand that HTML is not XML, but are you aware of a specific web
            browser that doesn't honor the distinction between XML declarations
            and processing instructions that is made in the XML recommendation?

            > > What if you don't have a DOCTYPE?
            > The default rendering is quirks mode and user agents do the best they can to guess at the rendering model and DOM, but that guessing opens wild variance that defeats cross browser conformity. Absense of a doctype destroys standards compliance back until HTML 2, which predates the standardized specification of the DOM. In accordance with the standards the doctype declaration is required since HTML 3 and HTML 3.2.
            > > JSLint doesn't allow comments before the root element html even if there is no DOCTYPE.
            > JSLint is enforcing a good practice. I urge you to follow it.
            >
            > Why would you want to suggest a change to JSLint in favor of a practice that exposes considerable costs and risks to management of HTML documents?

            I agree that JSLint shouldn't be changed to allow something that
            causes a problem for one of the major browsers.

            Can you tell me if one of the major browsers would have a problem with
            the following?

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <!-- some comment -->
            <html>
              <head>
                <title>some title</title>
              </head>
              <body>
              </body>
            </html>

            --
            R. Mark Volkmann
            Object Computing, Inc.
          • Mark Volkmann
            See correction below. On Wed, Feb 10, 2010 at 6:00 AM, Mark Volkmann ... There is no such thing as a getProcessingInstructions method in DOM Document. I should
            Message 5 of 22 , Feb 10, 2010
            • 0 Attachment
              See correction below.

              On Wed, Feb 10, 2010 at 6:00 AM, Mark Volkmann
              <r.mark.volkmann@...> wrote:
              > On Tue, Feb 9, 2010 at 11:23 PM, Cheney, Edward A SSG RES USAR USARC
              > <austin.cheney@...> wrote:
              >>
              >> Any tag that is delimited as <?xml is an XML processing declaration. Several such declarations may occur in an XML document and preceed schema validation.
              >
              > Maybe I can learn something new here. Can you point me to a
              > description of the term "XML processing declaration"? It is my
              > understanding that there are "XML declarations" and "processing
              > instructions" and that an "XML declaration" is not considered to be a
              > kind of "processing instruction" even though they have the same
              > syntax. There are two reasons why I think this distinction is
              > important. First, when the DOM Document getProcessingInstructions
              > method is called, it will not return the XML declaration.

              There is no such thing as a getProcessingInstructions method in DOM
              Document. I should have said getChildNodes.

              > Second, the
              > recommendation says that comments cannot proceed the XML declaration,
              > but can proceed processing instructions.
              > I understand that HTML is not XML, but are you aware of a specific web
              > browser that doesn't honor the distinction between XML declarations
              > and processing instructions that is made in the XML recommendation?
              >
              >> > What if you don't have a DOCTYPE?
              >> The default rendering is quirks mode and user agents do the best they can to guess at the rendering model and DOM, but that guessing opens wild variance that defeats cross browser conformity. Absense of a doctype destroys standards compliance back until HTML 2, which predates the standardized specification of the DOM. In accordance with the standards the doctype declaration is required since HTML 3 and HTML 3.2.
              >> > JSLint doesn't allow comments before the root element html even if there is no DOCTYPE.
              >> JSLint is enforcing a good practice. I urge you to follow it.
              >>
              >> Why would you want to suggest a change to JSLint in favor of a practice that exposes considerable costs and risks to management of HTML documents?
              >
              > I agree that JSLint shouldn't be changed to allow something that
              > causes a problem for one of the major browsers.
              >
              > Can you tell me if one of the major browsers would have a problem with
              > the following?
              >
              > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
              >  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
              > <!-- some comment -->
              > <html>
              >   <head>
              >     <title>some title</title>
              >   </head>
              >   <body>
              >   </body>
              > </html>

              --
              R. Mark Volkmann
              Object Computing, Inc.
            • Cheney, Edward A SSG RES USAR USARC
              ... I cannot find that method in any of the DOM specifications, so I have no response. ... I have never called a processing instruction through a DOM
              Message 6 of 22 , Feb 10, 2010
              • 0 Attachment
                > First, when the DOM Document getProcessingInstructions
                > method is called, it will not return the XML declaration.

                I cannot find that method in any of the DOM specifications, so I have no response.

                > I understand that HTML is not XML, but are you aware of a specific web
                > browser that doesn't honor the distinction between XML declarations
                > and processing instructions that is made in the XML recommendation?

                I have never called a processing instruction through a DOM reference, so I cannot answer that.

                > Can you tell me if one of the major browsers would have a problem with
                > the following?

                There is probably not a rendering problem associated with supplying a comment prior to the root element and after the document prolog.
              • Stefan Weiss
                ... Mark already corrected that (hours ago) in his follow-up message. ... The point is that there s no problem whatsoever with having comments before the root
                Message 7 of 22 , Feb 10, 2010
                • 0 Attachment
                  On 11/02/10 05:42, Cheney, Edward A SSG RES USAR USARC wrote:
                  >> First, when the DOM Document getProcessingInstructions
                  >> method is called, it will not return the XML declaration.
                  >
                  > I cannot find that method in any of the DOM specifications, so I have no response.

                  Mark already corrected that (hours ago) in his follow-up message.

                  >> Can you tell me if one of the major browsers would have a problem with
                  >> the following?
                  >
                  > There is probably not a rendering problem associated with supplying a
                  > comment prior to the root element and after the document prolog.

                  The point is that there's no problem whatsoever with having comments
                  before the root element. It's perfectly well-formed XML and XHTML, and
                  (as far as I can tell, the specs aren't open) also well-formed SGML. You
                  were talking about the XML declaration and processing instructions, but
                  none of these have anything to do with the document's root element. I
                  have never seen comments before the root element to have any effect at
                  all on quirks mode vs standard rendering, and I have never seen a
                  browser which failed to handle these comments correctly. You asserted
                  that the OP was "wrong" in his assessment (that they are valid), so I'll
                  repeat my request for a source, or at least an example to support your
                  position.


                  --
                  stefan
                • Cheney, Edward A SSG RES USAR USARC
                  ... If my answers to my opinions cannot be found in a standards specification or a commonly accepted best practices guidance they are formed from personal
                  Message 8 of 22 , Feb 11, 2010
                  • 0 Attachment
                    > You asserted that the OP was "wrong" in his assessment (that they
                    > are valid), so I'll repeat my request for a source, or at least an
                    > example to support your position.

                    If my answers to my opinions cannot be found in a standards specification or a commonly accepted best practices guidance they are formed from personal experience. Some of my personal XML experience is best not supplied here, but some of those works are online.
                  • Mark Volkmann
                    On Thu, Feb 11, 2010 at 3:21 AM, Cheney, Edward A SSG RES USAR USARC ... The HTML 4.01 Recommendation makes this very clear in section 7.1. See
                    Message 9 of 22 , Feb 11, 2010
                    • 0 Attachment
                      On Thu, Feb 11, 2010 at 3:21 AM, Cheney, Edward A SSG RES USAR USARC
                      <austin.cheney@...> wrote:
                      >
                      > > You asserted that the OP was "wrong" in his assessment (that they
                      > > are valid), so I'll repeat my request for a source, or at least an
                      > > example to support your position.
                      >
                      > If my answers to my opinions cannot be found in a standards specification or a commonly accepted best practices guidance they are formed from personal experience. Some of my personal XML experience is best not supplied here, but some of those works are online.

                      The HTML 4.01 Recommendation makes this very clear in section 7.1.
                      See http://www.w3.org/TR/1999/REC-html401-19991224/
                      Here's what it says:

                      "7.1 Introduction to the structure of an HTML document

                      An HTML 4 document is composed of three parts:

                      a line containing HTML version information,
                      a declarative header section (delimited by the HEAD element),
                      a body, which contains the document's actual content. The body may be
                      implemented by the BODY element or the FRAMESET element.

                      White space (spaces, newlines, tabs, and comments) may appear before
                      or after each section."

                      The last sentence says that comments can go anywhere. The only reason
                      I can see for JSLint to not allow comments anywhere is if that causes
                      a problem for a specific browser. If that's the case then I'd like to
                      know which browsers have the issue.

                      --
                      R. Mark Volkmann
                      Object Computing, Inc.
                    • Cheney, Edward A SSG RES USAR USARC
                      ... The root element is not one of three sections that you stated in accordance with para 7.1 of HTML 4.
                      Message 10 of 22 , Feb 12, 2010
                      • 0 Attachment
                        > White space (spaces, newlines, tabs, and comments) may appear before
                        > or after each section."

                        The root element is not one of three sections that you stated in accordance with para 7.1 of HTML 4.
                      • Mark Volkmann
                        On Fri, Feb 12, 2010 at 5:01 AM, Cheney, Edward A SSG RES USAR USARC
                        Message 11 of 22 , Feb 12, 2010
                        • 0 Attachment
                          On Fri, Feb 12, 2010 at 5:01 AM, Cheney, Edward A SSG RES USAR USARC <
                          austin.cheney@...> wrote:

                          >
                          >
                          > > White space (spaces, newlines, tabs, and comments) may appear before
                          > > or after each section."
                          >
                          > The root element is not one of three sections that you stated in accordance
                          > with para 7.1 of HTML 4.
                          >

                          How about "a line containing HTML version information". Isn't that the
                          DOCTYPE? Isn't that before the root element?

                          --
                          R. Mark Volkmann
                          Object Computing, Inc.


                          [Non-text portions of this message have been removed]
                        • Cheney, Edward A SSG RES USAR USARC
                          Yes, putting anything, except whitespace characters, alters how several browsers perceive rendering of the DOM. This is most noticable in IE with regard to
                          Message 12 of 22 , Feb 12, 2010
                          • 0 Attachment
                            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:

                            http://www.travelocity.com/mediakit/index.html

                            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.

                            Austin
                          • Mark Volkmann
                            On Fri, Feb 12, 2010 at 5:56 AM, Cheney, Edward A SSG RES USAR USARC
                            Message 13 of 22 , Feb 12, 2010
                            • 0 Attachment
                              On Fri, Feb 12, 2010 at 5:56 AM, Cheney, Edward A SSG RES USAR USARC <
                              austin.cheney@...> wrote:

                              >
                              >
                              > 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:
                              >
                              > http://www.travelocity.com/mediakit/index.html
                              >
                              > 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.
                              >
                              I wish you were able to provide a simple example and tell me exactly what I
                              should see that is wrong in a specific browser. I'd gladly drop this
                              discussion and be in favor of the current JSLint restriction if you could do
                              that.

                              > 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.
                              >
                              Why do you feel that is logical? The root element is a child of the DOM
                              Document object. Comments before or after the root element are children of
                              the DOM Document object.

                              --
                              R. Mark Volkmann
                              Object Computing, Inc.


                              [Non-text portions of this message have been removed]
                            • Cheney, Edward A SSG RES USAR USARC
                              I am sorry, but it is not that simple. If you place a comment above the doctype and refresh the page in IE the rendering changes are obvious. In many other
                              Message 14 of 22 , Feb 12, 2010
                              • 0 Attachment
                                I am sorry, but it is not that simple. If you place a comment above the doctype and refresh the page in IE the rendering changes are obvious. In many other browsers problems may be present, but can be diffecult to identify if any problems actually exist. The idea in that example is that it is a perfect test sample since extremely simple HTML with extremely complicated CSS. Placing a comment above the doctype makes for a more obvious test, but placing a comment between the doctype and the root element may not make for an obvious test on display and may only become obvious when attempting to gather the comment as a node in the DOM.

                                > Why do you feel that is logical? The root element is a child of the DOM
                                > Document object.

                                The logic, or my logic, is inherent to my experience writing schema and representation of a node tree there in. This logic of mine is exemplified by some feature I have developed that may or may not extend what is a document object, and I am not willing to harm you through receipt of unintended disclosure.

                                Austin
                              • Mark Volkmann
                                I don t want to place a comment above the DOCTYPE. This is what I want to do: some
                                Message 15 of 22 , Feb 12, 2010
                                • 0 Attachment
                                  I don't want to place a comment above the DOCTYPE. This is what I want to
                                  do:

                                  <!DOCTYPE html whatever>
                                  <!-- some comment -->
                                  <html>
                                  <head>
                                  <title>some title</title>
                                  </head>
                                  <body>
                                  </body>
                                  </html>

                                  You are asking me to just trust you because you say you have seen this cause
                                  a problem in a past project but it seems that you can't demonstrate the
                                  issue or point to any "standard" that says its a bad idea. I guess I'm not
                                  enough of a trusting person. ;-) I'd really like to see an example of the
                                  problem that occurs when a comment is placed between the DOCTYPE and the
                                  html root element.

                                  On Fri, Feb 12, 2010 at 10:56 AM, Cheney, Edward A SSG RES USAR USARC <
                                  austin.cheney@...> wrote:

                                  >
                                  >
                                  > I am sorry, but it is not that simple. If you place a comment above the
                                  > doctype and refresh the page in IE the rendering changes are obvious. In
                                  > many other browsers problems may be present, but can be diffecult to
                                  > identify if any problems actually exist. The idea in that example is that it
                                  > is a perfect test sample since extremely simple HTML with extremely
                                  > complicated CSS. Placing a comment above the doctype makes for a more
                                  > obvious test, but placing a comment between the doctype and the root element
                                  > may not make for an obvious test on display and may only become obvious when
                                  > attempting to gather the comment as a node in the DOM.
                                  > > Why do you feel that is logical? The root element is a child of the DOM
                                  > > Document object.
                                  >
                                  > The logic, or my logic, is inherent to my experience writing schema and
                                  > representation of a node tree there in. This logic of mine is exemplified by
                                  > some feature I have developed that may or may not extend what is a document
                                  > object, and I am not willing to harm you through receipt of unintended
                                  > disclosure.
                                  >
                                  > Austin
                                  >

                                  --
                                  R. Mark Volkmann
                                  Object Computing, Inc.


                                  [Non-text portions of this message have been removed]
                                • Cheney, Edward A SSG RES USAR USARC
                                  Not exactly. I am saying I have seen in past projects how this condition is potentially problematic when the technology is pushed beyond current
                                  Message 16 of 22 , Feb 12, 2010
                                  • 0 Attachment
                                    Not exactly. I am saying I have seen in past projects how this condition is potentially problematic when the technology is pushed beyond current implementations. In other words, there are use cases, not previously considered in the most current DOM specification, that when applied in an instance appear to be problematic in this condition.

                                    > I guess I'm not enough of a trusting person.
                                    I can demonstrate this potentially problematic condition, but I have already mentioned I will not harm you with such a demonstration. If such harm is of no concern then simply contact the legal department of Sabre Holdings and ask permission to examine IP attached to my name. I do not own the IP and you must volunteer to an administering party to receive disclosure. Otherwise you would have to find the related contents online and examine them independently of any assistance from me.

                                    At this point I believe the discussion has the field of association to the JSLint tool and if the discussion is to continue then I ask that you please contact me directly and only after contacting my legal representatives. Until such I cannot continue this conversation.
                                  Your message has been successfully submitted and would be delivered to recipients shortly.