From 892eb9d6b3b30a26c9ea4ad1d640c6b8792fa2a9 Mon Sep 17 00:00:00 2001 From: tjcrowder Date: Fri, 9 Oct 2009 15:34:39 +0100 Subject: [PATCH] doc: Merged/updated old docs for Element.childElements / Element.immediateDescendants. Made immediateDescendants an alias of childElements rather than vice-versa as the latter is depreceated. --- src/dom/dom.js | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index 050562e..37bc839 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -527,11 +527,10 @@ Element.Methods = { return $(element); }, - /** + /** deprecated, alias of: Element.childElements * Element.immediateDescendants(@element) -> [Element...] * - * Collects all of `element`'s immediate descendants (i.e., children) and - * returns them as an array of elements. + * **This method is deprecated, please see [[Element.childElements]]**. **/ immediateDescendants: function(element) { if (!(element = $(element).firstChild)) return []; @@ -1302,8 +1301,40 @@ Object.extend(Element.Methods, { **/ getElementsBySelector: Element.Methods.select, - /** alias of: Element.immediateDescendants + /** * Element.childElements(@element) -> [Element...] + * + * Collects all of the element's children and returns them as an array of + * [extended](http://prototypejs.org/api/element/extend) elements, in + * document order. The first entry in the array is the topmost child of + * `element`, the next is the child after that, etc. + * + * Like all of Prototype's DOM traversal methods, `childElements` ignores + * text nodes and returns element nodes only. + * + * ##### Example + * + * Assuming: + * + * language: html + *
+ * Some text in a text node + *
+ *
+ *
+ *
+ *
+ * + * Then: + * + * $('australopithecus').childElements(); + * // -> [div#homo-erectus] + * + * $('homo-erectus').childElements(); + * // -> [div#homo-neanderthalensis, div#homo-sapiens] + * + * $('homo-sapiens').childElements(); + * // -> [] **/ childElements: Element.Methods.immediateDescendants });