The existence of document.getElementById doesn't imply you can "do
whatever you want with it". It only implies that the browser
supports getElementById, any further uses of it you still need to
test for.
If we want to take that line of thought to the limit, all it shows is
that the value of the property "document" of the global object is
itself an object (or is convertible to one), and that it has a
property called "getElementById" that has a value that is not
convertible to "false".
We might also need to check that "document" really refers to a
document, that getElementById is a function, and that it takes an
argument and returns a DOM node that has that argument as an ID
attribute.
We should also test that we are really running a version of
Javascript, and that the Javascript interpreter works correctly for
all the language constructs that we use.
This is ofcourse ridiculous. We have to draw a line somewhere, and
assume that everything below that line works to our assumtions.
What I say is that, in my opinion, which I prefer to think of as
informed, the line can be drawn at the existence of a "getElementById"
propertyin the "document" object (which is assumed to exist). If
"getElementById" exists, then I will use it and assume that it is
indeed an implementation of the method specified in the DOM 2 Core W3C
recommendation.
I haven't yet seen a browser where that assumption fails, and I don't
expect to see on.
Not the use of getElementById, but the methods of it need to be
tested as well.
What is the "use" and "methods" of "getElementById"?
/L