Re: [WSG] Firefox DOM and whitespace (bug?)

2005-08-05 Thread Ben Curtis


On Aug 4, 2005, at 2:45 PM, Patrick Ryan wrote:


User agents have always (and will always) ignore whitespace in their
display of XHTML.  Should the DOM ignore it too?  I recognize that's
kind of backward logic, but it's certainly the practical view.



Useragents better *not* ignore whitespace in their parsing of XHTML,  
since any element can be styled with white-space:pre;


They only ignore the whitespace if the CSS tells them to, and even  
then it needs to be stored in the DOM somehow because you may change  
what styles get applied at any moment. In short, the whitespace is  
and always will be important to keep track of, even if it is  
routinely discarded during rendering.


It would be interesting to create a test case to see if IE parses the  
DOM differently based on whether the element in question preserves  
whitespace, and if that parsing changes when the white-space property  
changes


--

Ben Curtis : webwright
bivia : a personal web studio
http://www.bivia.com
v: (818) 507-6613




**
The discussion list for  http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list  getting help
**



[WSG] Firefox DOM and whitespace (bug?)

2005-08-04 Thread Patrick Ryan
I recently ran across an issue (I would call it a bug?) in firefox's DOM.

I wrote a rather lengthy bit on it here:
http://www.agavegroup.com/?p=32

But in short, firefox considers whitespace (tab, space, new line) to
be nodes in the DOM.  I've browsed the W3C spec, as well as the
Mozilla DOM spec and I can't come up with anything that demonstrates
how this should be handled.

But it seems to me white space should be entirely ignored in the DOM.

I just wanted to see if anyone else has run into this, and hear some
thoughts.  IE handles this differently (no surprise there...) and in
this case, better.  Is this a recent Firefox bug or proper behavior
(that must be scripted around...).

I'd be interested in any other thoughts/ideas.

Thanks,
Patrick
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**



Re: [WSG] Firefox DOM and whitespace (bug?)

2005-08-04 Thread Rimantas Liubertas
On 8/4/05, Patrick Ryan [EMAIL PROTECTED] wrote:
 I recently ran across an issue (I would call it a bug?) in firefox's DOM.
...
 But it seems to me white space should be entirely ignored in the DOM.
... Is this a recent Firefox bug or proper behavior
 (that must be scripted around...).
 
 I'd be interested in any other thoughts/ideas.

http://www.mozilla.org/docs/dom/technote/whitespace/

Regards,
Rimantas
-- 
http://rimantas.com/
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**



Re: [WSG] Firefox DOM and whitespace (bug?)

2005-08-04 Thread Ben Curtis


On Aug 4, 2005, at 1:39 PM, Patrick Ryan wrote:

I recently ran across an issue (I would call it a bug?) in  
firefox's DOM.

...

But in short, firefox considers whitespace (tab, space, new line) to
be nodes in the DOM.

...

But it seems to me white space should be entirely ignored in the DOM.

...

IE handles this differently (no surprise there...) and in
this case, better.  Is this a recent Firefox bug or proper behavior
(that must be scripted around...).



Firefox is right, I believe, because the DOM is defined like this:

The DOM presents documents as a hierarchy of Node objects
that also implement other, more specialized interfaces.[1]

The whitespace is part of the document, therefore the DOM must  
present it within the hierarchy of Nodes. In this case, it is a Text  
node (defined on the same page).


The proper way to parse a Nodelist is to not assume you know what is  
next, but to test what Nodetype the next child is, and then tailor  
your operation to fit (e.g., skip the whitespace and gimme the next  
node). Admittedly, the IE model would make some of my scripts easier  
to write, but then we'd lose the capability of the DOM to work with  
XML such that *everything* is a node, and HTML would be a special  
case that ignores whitespace.


Enough special cases, and the standard ain't so standard. So I think  
we need to keep coding with tests for Nodetype.




1. http://www.w3.org/TR/DOM-Level-2-Core/core.html

--

Ben Curtis : webwright
bivia : a personal web studio
http://www.bivia.com
v: (818) 507-6613




**
The discussion list for  http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list  getting help
**



Re: [WSG] Firefox DOM and whitespace (bug?)

2005-08-04 Thread Patrick Ryan
Thank you for the excellent reponses.  I can't believed I missed the
whitespace document
(http://www.mozilla.org/docs/dom/technote/whitespace/)

I see the point, and from a one standard fits all perspective, it
makes good sense.

I do have to wonder though:  The point of defining a DOM is to give
you a structure to work with.  And it's OK to create sort of sub
DOMs.  For example the XML DOM is basically a child of the SGML DOM. 
In other words while standard, the DOM was changed for XML (and
therefore XHTML) to better suit XML.

User agents have always (and will always) ignore whitespace in their
display of XHTML.  Should the DOM ignore it too?  I recognize that's
kind of backward logic, but it's certainly the practical view.

Anyway, as they say - learn something new every day.

Thanks for the reponses.

-- 
Patrick Ryan
http://www.agavegroup.com



On 8/4/05, Ben Curtis [EMAIL PROTECTED] wrote:
 
 On Aug 4, 2005, at 1:39 PM, Patrick Ryan wrote:
 
  I recently ran across an issue (I would call it a bug?) in
  firefox's DOM.
 ...
  But in short, firefox considers whitespace (tab, space, new line) to
  be nodes in the DOM.
 ...
  But it seems to me white space should be entirely ignored in the DOM.
 ...
  IE handles this differently (no surprise there...) and in
  this case, better.  Is this a recent Firefox bug or proper behavior
  (that must be scripted around...).
 
 
 Firefox is right, I believe, because the DOM is defined like this:
 
  The DOM presents documents as a hierarchy of Node objects
  that also implement other, more specialized interfaces.[1]
 
 The whitespace is part of the document, therefore the DOM must
 present it within the hierarchy of Nodes. In this case, it is a Text
 node (defined on the same page).
 
 The proper way to parse a Nodelist is to not assume you know what is
 next, but to test what Nodetype the next child is, and then tailor
 your operation to fit (e.g., skip the whitespace and gimme the next
 node). Admittedly, the IE model would make some of my scripts easier
 to write, but then we'd lose the capability of the DOM to work with
 XML such that *everything* is a node, and HTML would be a special
 case that ignores whitespace.
 
 Enough special cases, and the standard ain't so standard. So I think
 we need to keep coding with tests for Nodetype.
 
 
 
 1. http://www.w3.org/TR/DOM-Level-2-Core/core.html
 
 --
 
  Ben Curtis : webwright
  bivia : a personal web studio
  http://www.bivia.com
  v: (818) 507-6613
 
 
 
 
 **
 The discussion list for  http://webstandardsgroup.org/
 
  See http://webstandardsgroup.org/mail/guidelines.cfm
  for some hints on posting to the list  getting help
 **
 

**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**