most javascript libraries contain lines similar to:
var b = (a ? a.ownerDocument || a: 0).documentElement;
if a
is null
, what is (0).documentElement
supposed to return?
documentElement returns the Element that is the root element of the document (for example, the <html> element for HTML documents).
The getElementById() method returns an element with a specified value. The getElementById() method returns null if the element does not exist. The getElementById() method is one of the most common methods in the HTML DOM. It is used almost every time you want to read or edit an HTML element.
Document.getElementById() The Document method getElementById() returns an Element object representing the element whose id property matches the specified string. Since element IDs are required to be unique if specified, they're a useful way to get access to a specific element quickly.
var element = document. getElementById("YourElementId"); Using a different strategy, which is described below with code samples, the identical issue How To Get Element By Id In Node Js can be resolved. var myElement=document.
From jQuery
/ Sizzle
comments:
http://jsapi.info/jquery/1.7.2/jQuery.isXMLDoc
documentElement is verified for cases where it doesn't yet exist (such as loading iframes in IE - #4833)
So it's just cute syntax for returning undefined
- this is a result of calling documentElement
on 0
.
In next line there is check:
return documentElement ? documentElement.nodeName !== "HTML" : false;
So it returns false anyway.
most probably: undefined what else?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With