Peter said:
[...] David Mark [...] wrote:
[...] Peter Michaux [...] wrote:
[...] David Mark [...] wrote:
[...] Thomas 'PointedEars' Lahn [...] wrote:
Peter Michaux wrote:
[...]
There is no need to check for the existence of "document" as no
browser, NN4+ and IE4+, missing "document".
There is no need to check that document.getElementById is a callable
since there has never been a known implementation where
document.getElementById that is not callable.
If these are the guidelines for your project, to produce code that is not
interoperable and inherently unreliable, I don't want to contribute.
I somewhat agree with that sentiment,
I would say your codes says otherwise and that you agree that a line
for feature testing should be drawn somewhere.
I was talking about the issue he was referring to (gEBTN for document
vs. element.)
JFTR: I was not referring to that at all.
[...] I think I meant the following.
if (document.getElementById &&
typeof getAnElement != 'undefined' &&
getAnElement().getElementById) {
var getEBI = function(id, d) {
return (d||document).getElementById(id);
};
}
The nonsense gets worse.
Since the getElementById method is specified separately for Document
and Element in the DOM2 spec,
No, it is not. I don't know which DOM 2 Spec you have been reading,
but the one I have been reading specifies only:
,-<
http://www.w3.org/TR/DOM-Level-2-Core/core.html#i-Document>
|
| [...]
| interface Document : Node {
| [...]
| // Introduced in DOM Level 2:
| Element getElementById(in DOMString elementId);
| };
,-<
http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-745549614>
|
| [...]
| interface Element : Node {
| readonly attribute DOMString tagName;
| DOMString getAttribute(in DOMString name);
| void setAttribute(in DOMString name,
| in DOMString value)
| raises(DOMException);
| void removeAttribute(in DOMString name)
| raises(DOMException);
| Attr getAttributeNode(in DOMString name);
| Attr setAttributeNode(in Attr newAttr)
| raises(DOMException);
| Attr removeAttributeNode(in Attr oldAttr)
| raises(DOMException);
| NodeList getElementsByTagName(in DOMString name);
| // Introduced in DOM Level 2:
| DOMString getAttributeNS(in DOMString namespaceURI,
| in DOMString localName);
| // Introduced in DOM Level 2:
| void setAttributeNS(in DOMString namespaceURI,
| in DOMString qualifiedName,
| in DOMString value)
| raises(DOMException);
| // Introduced in DOM Level 2:
| void removeAttributeNS(in DOMString namespaceURI,
| in DOMString localName)
| raises(DOMException);
| // Introduced in DOM Level 2:
| Attr getAttributeNodeNS(in DOMString namespaceURI,
| in DOMString localName);
| // Introduced in DOM Level 2:
| Attr setAttributeNodeNS(in Attr newAttr)
| raises(DOMException);
| // Introduced in DOM Level 2:
| NodeList getElementsByTagNameNS(in DOMString namespaceURI,
| in DOMString localName);
| // Introduced in DOM Level 2:
| boolean hasAttribute(in DOMString name);
| // Introduced in DOM Level 2:
| boolean hasAttributeNS(in DOMString namespaceURI,
| in DOMString localName);
| };
The item on the left is the *return type* of the method, not its
(additional) owner.
a feature test for one does not assure the other is present.
A test for both is necessary if the getEBI
function is to be documented as suitable for both.
If what you stated above were the case, a test on an arbitrary element
object would not be sufficient. But it is not the case, so that point
is rather moot.
PointedEars