From a64fb2661b644fb55311f208c5b5edefa19b68a5 Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Thu, 18 Apr 2019 08:46:58 +0300 Subject: [PATCH] fix --- 2-ui/1-document/03-dom-navigation/article.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/2-ui/1-document/03-dom-navigation/article.md b/2-ui/1-document/03-dom-navigation/article.md index f19b3307..1e1e4058 100644 --- a/2-ui/1-document/03-dom-navigation/article.md +++ b/2-ui/1-document/03-dom-navigation/article.md @@ -237,7 +237,12 @@ alert( document.documentElement.parentElement ); // null In other words, the `documentElement` (``) is the root node. Formally, it has `document` as its parent. But `document` is not an element node, so `parentNode` returns it and `parentElement` does not. -Sometimes that matters when we're walking over the chain of parents and call a method on each of them, but `document` doesn't have it, so we exclude it. +This loop travels up from an arbitrary element `elem` to ``, but not to the `document`: +```js +while(elem = elem.parentElement) { + alert( elem ); // parent chain till +} +``` ```` Let's modify one of the examples above: replace `childNodes` with `children`. Now it shows only elements: