It is currently Sat Dec 02, 2017 4:15 pm Advanced search
Comments that contain the string "-->" can be represented in "DOM5 HTML" but not in "HTML5" and "XHTML5".
8.2.4.1 Initial phase
...
As far as parsing goes, the quirks I know of are:
...
The following is considered one script block (!):
<script><!-- document.write('</script>'); --></script>
Jarvklo wrote:Quick question:
What's the status on backwards compatibility "commenting" syntax (i.e.
<!-- --> and <![CDATA[ ]]>) inside <script type="text/javascript"> and <style type="text/css"> elements in (X)HTML5?
<style><!-- --></style>
<style><!-- --></style>
<!--[CDATA[ ]]-->
You cannot serve a DOM tree over the wire. The DOM is the browser's in memory representation of the document, which might come from script, or from parsing text/html, or from parsing XML. HTML5 (the language) is defined in terms of the DOM; HTML5 (text/html) and XHTML5 (XML) are serialization forms of that language. Any serialization format that can represent a tree could possibly represent an HTML5 document just like XML can, for instance you could imagine JSON or SGML, but their usefulness in practice is questionable.wgabrie wrote:In the html 5 spec, section 1.4.1 HTML vs XHTML there are three ways to serve html 5.
1. DOM5 HTML (I have no idea)
2. HTML 5 (text/html)
3. XHTML 5 (application/xhtml+xml)
The HTML5 spec only observes that it is possible for the DOM (that is defined in another spec) to contain comments with "-->" as data, and such a comment can't be serialized to HTML or XML (but could perhaps be serialized to say JSON), since that would represent the end of the comment. To end up in this situation in practice you would have a script to modify the DOM like so:wgabrie wrote:Comments that contain the string "-->" can be represented in "DOM5 HTML" but not in "HTML5" and "XHTML5".
This makes no sence to me. If HTML 5 (text/html) is going to be backwards compatible with previous HTML versions than why make comment strings only usable in DOM html (whatever that is)?
var comment = document.createComment(" foo --> bar ");
document.body.appendChild(comment);
alert(document.body.innerHTML);
It's ugly, but it is what browsers do (IIRC, only Gecko in standards mode doesn't do this), and if content relies on it (probably likely), it would have to be specced. (I have some test cases on this. Also see http://lists.whatwg.org/pipermail/whatw ... 06932.html)wgabrie wrote:Update:
In another part of the spec I found this:8.2.4.1 Initial phase
...
As far as parsing goes, the quirks I know of are:
...
The following is considered one script block (!):
<script><!-- document.write('</script>'); --></script>
I don't know if that is good or bad news.
I think the only text about this in the spec currently that applies to authors isJarvklo wrote:The problem is, even based on this excellent information I still can't find the sections in the spec that describes this clearly
-- http://www.whatwg.org/specs/web-apps/cu ... k/#writingCDATA elements can have text, but the text must not contain the two character sequence "</" (U+003C LESS-THAN SIGN, U+002F SOLIDUS).
Could you elaborate on what you want the spec to say? (Do you want guidelines for authors as to how they should write their inline scripts and style sheets?)Jarvklo wrote:Are there any plans for a (non-normative perhaps?) section that clarifies this as clearly as for instance http://www.w3.org/TR/html4/interact/scr ... l#h-18.3.2 does for HTML4?
Old browsers that don't understand the style or script elements (introduced in HTML 3.2) will attempt render their contents. However, the strings "<!--" and "-->" are part of the CSS syntax, and "<!--" is equivalent to "//" in JavaScript, so authors who don't want to reveal their style sheets or scripts to users with such browsers can simply comment them out. [CSS21] [ECMA262]
- Code: Select all
<style>
<!--
...
-->
</style>
- Code: Select all
<script>
<!--
...
//-->
</script>
Hm. The "Writing HTML documents" section doesn't apply to XHTML5 at all... so I'm not sure what it should say. Just reiterate in the note (if it's added) that "This does not apply to XHTML" or something?Jarvklo wrote:Yep.
That, and some additional information about how the <!-- commenting practice by nescessity must be handled differently by authors using XHTML5
Ok. Makes sense since it isn't handled by HTML -- it's handled by CSS and JS (the latter still being de facto).Jarvklo wrote:One reasons I took this up in the first place was that I (very briefly) assumed that since the <!-- issue wasn't handled (or even mentioned) in the WA1-spec it was gone.
Agreed.Jarvklo wrote:Again - the spec is where some of us go to find out how things are supposed to work. IMHO making sure that details like this is covered in the spec and not "just being there for people to find out" in the conformance checker or the HTML5libraries cannot be a bad thing.
Well... Not quite IMHO.zcorpan wrote:Hm. The "Writing HTML documents" section doesn't apply to XHTML5 at all... so I'm not sure what it should say. Just reiterate in the note (if it's added) that "This does not apply to XHTML" or something?
<script type="text/javascript"><!-- //HTML style comment enclosing code in a script element --></script>
<script type="text/javascript"><![CDATA[ block of code enclosed in an explicit CDATA section //]]></script>
FWIW, even if they do include the comments (like most browsers do), they will still be comments in the DOM (as opposed to text nodes), so they still are not passed on to the CSS parser or JS engine.Jarvklo wrote:XML parsing is, for example, mentioned as a reason to exclude the use of <noscript> from XHTML5 documents... and since XML parsers aren't *required* to include comments in the resulting tree structures it is not quite clear from the current text IMHO how WA1 in an XHTML serialization handles this by design...
-- http://www.whatwg.org/specs/web-apps/cu ... #executingIf the script is inline, then, for scripting languages that consist of pure text, user agents must use the value of the DOM text attribute (defined below) as the script to execute, and for XML-based scripting languages, user agents must use all the child nodes of the script element as the script to execute.
-- http://www.whatwg.org/specs/web-apps/cu ... #the-styleAll descendant elements must be processed, according to their semantics, before the style element itself is evaluated. For styling languages that consist of pure text, user agents must evaluate style elements by passing the concatenation of the contents of all the text nodes that are direct children of the style element (not any other nodes such as comments or elements), in tree order, to the style system. For XML-based styling languages, user agents must pass all the children nodes of the style element to the style system.
I don't know nor care how this is best done. Do as you wish.zcorpan wrote:Hmm. So you effectively want http://wiki.whatwg.org/wiki/HtmlVsXhtml to be included as a non-normative appendix to the spec? Or referenced to by the spec (e.g. in the HTML vs. XHTML section)?
Well - this is IMHO unfortunate at best. It sort of makes it impossible to handle all aspects of eg. http://www.w3.org/TR/WCAG/#tech-scripts in XHTML5.zcorpan wrote:<noscript> isn't allowed in XHTML5 because it doesn't work in XHTML. In HTML it is parsed differently depending on whether scripting is enabled or not.
Eh, - Now I'm even more confused. I wouldnt *dream* of placing a document.write based script inside of a <noscript> even in HTML4 !That cannot be done with an XML parser. It's main use-case is also in combination with document.write() scripts, which also don't work in XML (it could perhaps be made to work, but it's unclear how), so it isn't really needed anyway.
Return to Feedback on the Specs
Users browsing this forum: No registered users and 0 guests