W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2007

[whatwg] parsing: bogus comments - PIs

From: Michael A. Puls II <shadow2531@gmail.com>
Date: Thu, 14 Jun 2007 03:24:15 -0400
Message-ID: <6b9c91b20706140024r4d68573l7968c12eb6eae598@mail.gmail.com>
On 6/13/07, Ian Hickson <ian at hixie.ch> wrote:
> On Wed, 26 Jul 2006, Shadow2531 wrote:
> > > >
> > > > So, <?xml-stylesheet type="text/css" href=""?> is a bogus comment.
> > > >
> > > > I *was* 100% sure that the PI should be parsed into:
> > > >
> > > > <!--?xml-stylesheet type="text/css" href=""?-->
> > >
> > > Correct.
> >
> > Thanks Ian. Can you comment on innerHTML for this situation?
> >
> > If <?xml-stylesheet type="text/css" href=""?> is parsed into
> > <!--?xml-stylesheet type="text/css" href=""?--> , what should
> > innerHTML show?
>
> Assuming you mean the .innerHTML of a parent element, it would show the
> comment as you've written it above. See the innerHTML definition in the
> spec:
>
>    http://www.whatwg.org/specs/web-apps/current-work/#innerhtml0

Thanks. That clears it up now.

My notes for reference:

Given HTML5 markup:
<div id="test"><?xml-stylesheet type="text/css" href=""?></div>

Since PIs in markup are parsed as bogus comments, the above is parsed as:
<div id="test"><!--?xml-stylesheet type="text/css" href=""?--></div>
and the comment is parsed into the DOM as a comment node.

document.getElementById("test").innerHTML should then return the string:
<!--?xml-stylesheet type="text/css" href=""?-->
because that's what
"<!--" + document.getElementById("test").data + "-->"
should equal.

Required changes:
Since Firefox, IE, Opera and Safari do not conform to this:

Firefox and Safari will have to stop ignoring PIs in markup and treat
them as comments.
Opera and IE will have to start treating PIs in markup as comments.

-- 
Michael
Received on Thursday, 14 June 2007 00:24:15 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:56 UTC