S
szimek
Hi!
Like many others before recently I've found out that firstChild works
little bit differently in IE and other browsers. I've got huge app
that is currently IE only and used firstChild all over the place.
Currently I wrote my own function firstNonTextChild(element), but it
would be much more convenient for me to modify element.firstChild
directly for FF and others, so I wouldn't have to change the code.
The problem is that my current function looks like this:
function firstNonTextChild(element) {
var e = element.firstChild;
// Fetch next element unless non-text node is fetched
while(e.nodeType == 3) {
e = e.nextSibling;
}
return e;
}
As you can see it gets firstChild property itself. Is it possible to
make an alias or something for the original firstChild property, so I
could do
HTMLElement.prototype.firstChild = function() {
....
element.originalFirstChild;
....
}
And one more thing, my "solution" creates a method, not a property
like the original firstChild. How can I modify this code to make
modified firstChild a property and not a function?
Like many others before recently I've found out that firstChild works
little bit differently in IE and other browsers. I've got huge app
that is currently IE only and used firstChild all over the place.
Currently I wrote my own function firstNonTextChild(element), but it
would be much more convenient for me to modify element.firstChild
directly for FF and others, so I wouldn't have to change the code.
The problem is that my current function looks like this:
function firstNonTextChild(element) {
var e = element.firstChild;
// Fetch next element unless non-text node is fetched
while(e.nodeType == 3) {
e = e.nextSibling;
}
return e;
}
As you can see it gets firstChild property itself. Is it possible to
make an alias or something for the original firstChild property, so I
could do
HTMLElement.prototype.firstChild = function() {
....
element.originalFirstChild;
....
}
And one more thing, my "solution" creates a method, not a property
like the original firstChild. How can I modify this code to make
modified firstChild a property and not a function?