ですから、body、単一の div、およびいくつかのテキストを含む段落要素を含む非常に基本的なページがあるとしましょう。
<body>
<div>
<p>some text</p>
<div>
</body>
ブラウザーによっては、body / div 要素にテキスト ノード (nodeType === 3、nodeValue === "--blank--") が含まれます。ただし、P 要素には、nodeValue === "some text" を持つ正当なテキスト ノードがあります。
私が疑問に思っているのは、空白を表す「偽の」テキストノードの「nodeValue」(--blank--) が何であるかということです。偽のテキストノードを除外できる if テストを書きたいからです.
例:
var body = document.getElementsByTagName("body")[0]; // shortcut to body element.
console.log(body.childNodes[0].nodeValue) // maps to one of the fake text nodes that are blank.
// returns a blank line. What is that "blank" equal to? It's not 'null' or "" or undefined...
乾杯、アレックス