Ага. Ну чтобы не фантазировать, что кому должен, и какая реализация, что решает, полезли в W3C читать доки:
Цитата:
Сообщение от W3C
The Document interface represents the entire HTML or XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data. Interface Document
|
Здесь сказано, что document является root-элементом дерева. Смотрим там же дальше интерфейс:
Цитата:
Сообщение от W3C
interface Document : Node {
…
NodeList getElementsByTagName(in DOMString tagname);
…
};
|
О_о getElementsByTagName есть у document по стандарту, листаем дальше:
Цитата:
Сообщение от W3C
getElementsByTagName
Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.
|
Говорится про Document tree, ничего про отдельную ветку с <body> не сказано.
Так почему надо искать <head> с помощью document.documentElement.getElementsByTagName("hea d"), а не document.getElementsByTagName("head")?
|