[whatwg] parsing: bogus comments - PIs

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