TEXT_NODE

テキスト節点 (DOM)

[2] Text 節は、 Element 節や Attr 節の中の文内容 (XML の用語では文字データ) を取扱います。

[1] DOM1 では、文節 (Text node) はどんな種類の子も持つことは出来ません。

[4] CharacterData を継承して:

methodsplitText文節を分割[DOM1]

[3] 親節の中で、文節が隣接することができますが、 それは XML 的には保存されません。例えば、

 <element>
  +-- "text1"
  +-- "text2"

という文書木 (の断片) は存在し得ますが (そして DOM を使った処理の結果木としてしばしば作られますが)、 この木を一旦他の形式に直し、再び DOM 木にした時に、 一般には元には戻りません。

 XML 文書として保存:
   <element>text1text2</element>
 再び DOM 木を作成:
   <element>
    +-- "text1text2"

DOM 木で XPointersXPath を使う時には、 この点に気をつける必要があるかもしれません。

[8] 不要なテキストノードの除去 - 0x集積蔵 ( 版) http://d.hatena.ne.jp/os0x/20081105/1225861584#c1225901215

li要素のouterHTMLプロパティの値を前後に引用符でもつけて表示してみればわかりますが、IEは要素間の空白文字列を要素の子テキストノードに取り込んでしまいます。

適合性

[20] Text 節点data の適合性は HTML Standard で規定されており、 Unicode文字のうち制御文字非文字を除いたものとなっています。

[22] XML 1.0 として表現可能な Char と比較すると次の違いがあります:

CDATASection 界面

[11] CDATASection DOM 界面Text 界面継承するものと定義されています。

[12]Text 節点」のような表現は TEXT_NODE だけなのか、 それとも CDATA_SECTION_NODE をも含むのか曖昧なので、注意が必要です。

nodeType TEXT_NODE

[13] テキスト節点nodeType 属性の値は Node 界面定数 TEXT_NODE (3) です。

[25] Text は、スロット可能です。

[26] 節点の状態、スロット可能の状態に加え、次の状態を持ちます。

隣接テキスト節点

[6] 構文解析器の出力では、テキスト節点が隣接することがありません。

[7] insertAdjacentText で隣接テキスト節点が生じることがあります。

関連

[9] XML情報集合では Text 節点文字情報項目の連続に相当します。

[10] XPath 1.0データ・モデルでは Text 節点テキスト節点に相当します。 ただし XPath 1.0 には TextCDATASection の区別がありません。

歴史

[14] Web Applications 1.0 r5298 Coalesce text nodes even if they're not parser-inserted.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10221 ( ( 版)) http://html5.org/tools/web-apps-tracker?from=5297&to=5298

[15] Web Applications 1.0 r6968 Hoist requirements on what text can consist of from the text/html syntax to the DOM, so it also applies to XML and script-provided data. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=6967&to=6968

[16] Add constructors for DocumentFragment, Text, and Comment. (DocumentType ... · a2f1e18 · whatwg/dom ( ( 版)) https://github.com/whatwg/dom/commit/a2f1e18ff56ecc12643dc54fcf50f0c335beec71

[17] HTML Standard ( ( 版)) http://www.whatwg.org/specs/web-apps/current-work/#text-content

[23] XQuery and XPath Data Model 3.0 ( ( 版)) http://www.w3.org/TR/xpath-datamodel-3/#TextNode

[24] Shadow: define slots and slotables · whatwg/dom@a2b04df ( 版) https://github.com/whatwg/dom/commit/a2b04df51b4342d7617c128e80e5aa892889d2e0

[27] Specify global object references in more detail (annevk著, ) https://github.com/whatwg/dom/commit/fa8adb6cd107cd845feaeb71c9da208971b670ca

[28] CDATASection nodes don't like to be normalized away (annevk著, ) https://github.com/whatwg/dom/commit/e8d5e65fd890ec0ba9299d7b63e911c3187275f9

[29] Editorial: use noncharacter and control from Infra (annevk著, ) https://github.com/whatwg/html/commit/70925237a88d9802bfe7224fe9c78b146af615be

[30] Align with IDL constructor changes (autokagami著, ) https://github.com/whatwg/dom/commit/57512fac17cf2f1c4c85be4aec178c8086ee5ee4

[31] Update to constructor operations · Issue #780 · whatwg/dom () https://github.com/whatwg/dom/issues/780