W3C home > Mailing lists > Public > www-style@w3.org > January 2010

Re: Text selector [was Re: breaking overflow]

From: Patrick Garies <pgaries@fastmail.us>
Date: Mon, 04 Jan 2010 23:43:52 -0600
Message-ID: <4B42D198.6060609@fastmail.us>
To: Brad Kemper <brad.kemper@gmail.com>
CC: Boris Zbarsky <bzbarsky@MIT.EDU>, www-style list <www-style@w3.org>
On 2010-01-04 12:46 AM, Brad Kemper wrote:
> On Jan 3, 2010, at 9:02 PM, Boris Zbarsky wrote:
>> Simple example #1:
>> <!DOCTYPE html> <body> <script>
>> document.body.appendChild(document.createTextNode("ba"));
>> document.body.appendChild(document.createTextNode("r")); </script>
> I see. I would treat that as if it were all one node, since there
> would seem to be little advantage to not doing so.

If you assign each of these statements to a variable, there's going to
be a problem getting and altering nodes that don't exist because you've
arbitrarily merged them with other nodes.

There can be advantages (other than variables) to having separate text
nodes as well. For example, you might pre-create a zero-length text node
that can have text added later via a more convenient mechanism such as
the DOM1/2/3 |CharacterData.data| property.

If you need to merge all of the text nodes, you can use the DOM1/2/3
|Node.normalize| method.

>> Simple example #2:
>> <!DOCTYPE html> <body> ba<!--comment, so the textnodes aren't even
>> quite adjacent in the DOM-->r
> Hmm. It is a bit murkier, but I think that treating the comment as
> though it were utter nothingness and as if "bar" was all part of the
> same node would be the right thing to do.

There's been a comment node type since DOM1, so you can't arbitrarily
scrap the node to merge the text nodes.

>> Simple example #4, equivalent to the above:
>> <!DOCTYPE html> <body> ba<script>document.write("r")</script>
> That would be right out., given my answer to #3. Even without it,
> this is now far from being "two adjacent textnodes" in my mind.

I never really thought about this. I decided to check what the resulting
DOM is, but all I get is a text node with "document.write("r")" in it in
Firefox's DOM Inspector extension which doesn't make any sense.
Received on Tuesday, 5 January 2010 05:44:28 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:31 UTC