とりあえず、Firefoxに関してはこうです。
Mozilla では、元のドキュメントのテキストコンテント中の空白文字は全て DOM 中にも表現されます(タグ内部の空白文字は除く)。
DOM 中の空白文字 - ウェブデベロッパーガイド | MDN
さて。
じゃあ、定義はどうなんだと調べてみたところ泥沼にハマりましたのでご報告します。
まずDOMlevel3にisElementContentWhitespace
というアトリビュートがありました。
isElementContentWhitespace of type boolean, readonly, introduced in DOM Level 3
Returns whether this text node contains element content whitespace, often abusively called 'ignorable whitespace'.
Document Object Model Core
適当訳すると、『テキストノードが、しばしば「無視してよい空白」と誤用されるelement content whitespace
かどうかを返します』でしょうか。
じゃあこのelement content whitespace
とは何かを調べてみると、
[element content whitespace] A boolean indicating whether the character is white space appearing within element content (see [XML], 2.10 "White Space Handling").
XML Information Set (Second Edition)
element content
に含まれる空白である、と。
じゃあ、element content
とはなんぞや。
[Definition: An element type has element content when elements of that type MUST contain only child elements (no character data), optionally separated by white space (characters matching the nonterminal S).]
Extensible Markup Language (XML) 1.0 (Fifth Edition)
『ある要素が、(文字を除く)子要素のみを持たなくてはいけない時、その要素はelement content
を持つ。ただし、空白によって区切られてもよい』とのこと。
つまり、isElementContentWhitespace
である空白とは、これのことではないかなあ、と。
で、この後に (characters matching the nonterminal S) の S が定義されてまして、
[3] S ::= (#x20 | #x9 | #xD | #xA)+
Extensible Markup Language (XML) 1.0 (Fifth Edition)
おなじみのスペース、タブ、LF、CR、ですね。
つまり、「要素の前後に入るスペース、タブ、LF、CR」が空白ノードになると思われ、これは先ほどのMDNの説明と合致するかと思います。
……とはいえ、これはXMLの定義の話ですので、いろいろ疑問点も出てきますので、他の回答者を待ちたいと思います。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/16 09:50
2016/12/22 10:41
2016/12/22 14:04
2016/12/27 10:50 編集
2016/12/26 14:01 編集
2016/12/27 10:55