Subj : Re: Redefining firstChild on prototype in firefox To : Mcginkel From : Brendan Eich Date : Wed Jun 08 2005 09:54 am Mcginkel wrote: > I am trying to change the default behaviour from firefox/mozilla to > behave exactly like IE for the firstChild property of an HTMLElement. I > want comment- and text-nodes with only whitespace to be skipped just > like IE does. > > I use the following code to get this behaviour : > > HTMLDivElement.prototype.__defineGetter__("firstChild", function() { > var node = this.childNodes[0]; > while (node && (node.nodeType == 8 || ( (node.nodeType == 3) && > !(/[^\t\n\r ]/.test(node.data))) )) > { > node = node.nextSibling; > } > return node; > }); > > The code works, but I have to do this for every type of Element > (HTMLDivElement, HTMLTableElement etc) while I would like to do this > once on HTMLElement so all elements get this behaviour. This should be possible, but beware Firefox 1.0.3 (http://developer-test.mozilla.org/en/docs/Working_around_the_Firefox_1.0.3_DHTML_regression). > I can do this with properties that are new (outerHTML etc), but not > with existing properties in firefox/mozilla. > > Any ideas if this is possible ? You are using the wrong newsgroup. See message headers. /be .