diff --git a/src/dom/dom.js b/src/dom/dom.js index 813a5ae..48d255f 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -860,7 +860,44 @@ Element.Methods = { /** * Element.cleanWhitespace(@element) -> Element * - * Removes whitespace-only text node children from `element`. + * Removes all of `element`'s child text nodes that contain *only* + * whitespace. Returns `element`. + * + * This can be very useful when using standard methods like `nextSibling`, + * `previousSibling`, `firstChild` or `lastChild` to walk the DOM. Usually + * you'd only do that if you are interested in all of the DOM nodes, not + * just Elements (since if you just need to traverse the Elements in the + * DOM tree, you can use [[Element.up]], [[Element.down]], + * [[Element.next]], and [[Element.previous]] instead). + * + * #### Example + * + * Consider the following HTML snippet: + * + * language: html + * + * + * Let's grab what we think is the first list item using the raw DOM + * method: + * + * var element = $('apples'); + * element.firstChild.innerHTML; + * // -> undefined + * + * It's undefined because the `firstChild` of the `apples` element is a + * text node containing the whitespace after the end of the `ul` and before + * the first `li`. + * + * If we remove the useless whitespace, then `firstChild` works as expected: + * + * var element = $('apples'); + * element.cleanWhitespace(); + * element.firstChild.innerHTML; + * // -> 'Mutsu' **/ cleanWhitespace: function(element) { element = $(element); diff --git a/vendor/pdoc b/vendor/pdoc index 147250b..fa11874 160000 --- a/vendor/pdoc +++ b/vendor/pdoc @@ -1 +1 @@ -Subproject commit 147250bd65eed627e32ca5a70b57fe4f7803ab4b +Subproject commit fa1187431a71d43c7b292feecd2dc5a61a6f630b