W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2009

Re: DOM4 Core (was: childElements, childElementCount, and children)

From: Laurens Holst <laurens.nospam@grauw.nl>
Date: Mon, 19 Oct 2009 14:04:16 +0200
Message-ID: <4ADC55C0.2060800@grauw.nl>
To: www-dom@w3.org
Hi,

I see .children [1] is being discussed, let me pitch in for a little:

.children interoperability is very bad, particularly the 
.children.tags() [2] method.

- Firefox 3.0 doesn’t have it,
- Firefox 3.5 implemented children collection but not tags() method 
(breaking my code in the process)
- Safari’s tags() method does not function well, I believe it does not 
only return direct children but works something like getElementsByTagName()
- Opera’s tags() method does not work in XHTML mode, it returns an array 
of undefined.

In my Selectors implementation [3] I was using .children.tags() to 
optimise looping over child nodes, if it is available. The lifecycle of 
that code’s guard went something like this:

Original guard:

   if (oNode.children)

Found Safari bug:

   if (oNode.children && !browser_webkit)

Firefox 3.5 was released:

   if (oNode.children && oNode.children.tags && !browser_webkit)

Found Opera bug:

   if (oNode.children && oNode.children.tags && !browser_webkit && 
!browser_opera)

Decided this was getting a bit rediculous:

   if (browser_ie)

So, the morale of this story: tread with caution. :)

~Laurens

[1] http://msdn.microsoft.com/en-us/library/ms537446%28VS.85%29.aspx
[2] http://msdn.microsoft.com/en-us/library/ms536776%28VS.85%29.aspx
[3] http://www.grauw.nl/projects/pc/selectors/

-- 
~~ Ushiko-san! Kimi wa doushite, Ushiko-san nan da!! ~~
Laurens Holst, developer, Utrecht, the Netherlands
Website: www.grauw.nl. Backbase employee; www.backbase.com




Received on Monday, 19 October 2009 12:04:51 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:04 GMT