RE: View Source


Lachlan Hunt wrote:

>There are problems that make simply reserialising the source less 
>valuable to developers than you might think.  Consider this fragment:

<p>A paragraph with <a href="#">a link</p>
<p>Another paragraph</p>

------------
Several thoughts about this topic in general (I just happened to reply to Lachy's message since it was a the top of my inbox) with no particular conclusion:

1. When I first saw TV Raman's suggestion yesterday I rather winced; there was a gut reaction against it, though not a lot of rationale for my reaction came to mind. Allowing that sensation to pass (and thanks to some clarification later in the thread), I warmed to the idea.

2. Access to a "cleaner" version of code (either that one has authored or found on the web) could result in cleaner authoring practices. That could be a good thing for teachers and make for a healthier web overall.

3. I think the issue is not necessarily off-topic for the HTML WG since a part of the charge involves propagating awareness of the spec. Promoting tidy code could be seen as consistent with that objective. I didn't go reread the mission statement, so am quite willing to be corrected.

4. Even if we do not agree with the way a browser serializes our document, it is nice to be able to eavesdrop on what it has done. The first time I discovered that a browser was inserting tags or attributes that I had not authored, into my code (it happens both in SVG and HTML), I joked with students that I should bring an infringement suit for creating unauthorized derivative work without permission of the copyright holder. (Yes, there was a grin on my face as I said that.)

5. I think a prevailing sentiment is that once HTML5 is done, authors will no longer need to invent clever quirky ways to get around browsers' limitations. I am not so sure this will ever happen. If it doesn't, then revealing (through "show source") only the canonical interpretation of an author's code (particularly as augmented by script) could rather dramatically miss the meaning of what a web page actually does. Access to both the original and the code-after-processing probably makes sense, possibly with the tidy version being more easy to access.

6. Will the DOMs associated with a tidy view of source and with the original source be the same? Does HTML5 fix all browser inconsistencies? For example will for (i in document) count++ eventually give the same value for count in all browsers?

For example, in this little web document (HTML)
<script>
window.onload=startup
function startup(){
 count=0;for (i in document) count++
 alert(count)
}
</script>

I see count being (IE 94) (Opera 134) (FF 149) (Chrome 130) (Safari 141). I realize this is probably an extreme example but somewhere in between inserting a <TBODY> into the DOM of a <table> (all browsers currently do this) and the above is a line the whereabouts of which I'm not sure enjoys universal agreement.

regards
David

Received on Tuesday, 17 March 2009 13:30:39 UTC