Re: Text selector [was Re: breaking overflow]

On Jan 4, 2010, at 4:15 AM, James Hopkins wrote:

> My thoughts on the following scenarios:-
> 
>> Simple example #1:
>> 
>> <!DOCTYPE html>
>> <body>
>> <script>
>> document.body.appendChild(document.createTextNode("ba"));
>> document.body.appendChild(document.createTextNode("r"));
>> </script>
> 
> The authors intention was to create two separate textnodes, thus they should be treated separately.

[...]
>> Example #6, which depends on exact behavior still being hammered out in the HTML5 spec:
>> 
>> <!DOCTYPE html>
>> <body><script>
>> document.write("ba"); document.write("r");
>> </script>
> 
> They're written as two separate entities, so should be treated as such.

I don't think you can assume the author's intention, and don't think they are necessary written separate for reasons other than coding convenience. Consider the following, for instance:

document.body.appendChild(document.createTextNode("bar"));
if(moreThanOneBar) {
  document.body.appendChild(document.createTextNode("s"));
}

or 

document.write("baz");
if(moreThanOneBaz) {
  document.write("es");
}

Received on Monday, 4 January 2010 17:05:31 UTC