子供テキスト内容

text 属性 (DOM)

[18] いくつかの HTML要素には、 text IDL属性があります。これは要素の内容からテキストを抽出するものです。

[19] textContent IDL属性と似ていますが、 動作が微妙に異なっていますし、すべての要素に存在するわけでもありません。

仕様書

子供テキスト内容

[23] 要素子供テキスト内容 (child text content) は、 当該要素子供である Text 節点すべてのデータを、 木順に連結したものです >>32, >>26

[28] 子供テキスト内容は、次の場面で使われます。

[25] このうち title, style, script については、HTML構文解析器内容部分でタグを認識しないので、 子要素を持つことはありません。 (DOM 操作により子要素挿入することはできますが。)

[24] 似たものに textContent がありますが、 子孫すべてのテキスト連結するものですから、 常時最新値を使う処理の場合に、 子孫のあらゆる変異を観測して適宜更新する必要があります。 それは必ずしも低コストな処理ではないため、子要素が特に必要なければ、 子テキストの連結が使われることがあります >>21

[29] option 要素子供テキスト内容textContent の中間のようなものを使っています。

HTMLScriptElement インターフェイス

[10] HTMLScriptElement インターフェイスtext IDL属性は、 取得時、次のようにしなければなりません >>9

  1. [12] テキストを、空文字列に設定します。
  2. [11] 文脈オブジェクト子供リストに含まれる節点節点について木順に、
    1. [13] 節点Text なら、
      1. [14] テキストの末尾に節点データを追加します。
  3. [15] テキストを返します。
[17] これは textContent とは違って子要素を無視します。 HTML構文では script 要素子要素を含めることはできませんが、 XHTMLスクリプトを使えば可能です。しかしスクリプトの実行時には textContent ではなく text の値が使われ、子要素内容スクリプトソースコードの一部とはみなされません。

[16] 設定時には、 textContent IDL属性設定器と同じようにしなければなりません >>9

変更手順群

[34] text が変化するとき、特定の処理が行われることがあります。 子供テキスト内容変更手順群

歴史

[20] text IDL属性IE4 DOM に由来します。

Node インターフェイス

[8] MSXML では Node インターフェイス相当に text 属性があるようです。

[7] >>6 によると標準の DOMtextContent に近いですが、 xml:space 属性などによって挙動が変わるようです。

HTML5

[2] >>1HTMLAnchorElementtext 属性が定義されました。

[5] >>4HTMLOptionElementtext 属性の定義が改められています。

共通化

[33] 2016年、従来個別に定義されていた本概念に子供テキスト内容という名前が与えられました。

[21] Validity and processing should be aligned for <time> · Issue #644 · whatwg/html ( 版) https://github.com/whatwg/html/issues/644

[22] Fix #644: Only look at child Text nodes in <time> · whatwg/html@b437a80 ( 版) https://github.com/whatwg/html/commit/b437a803c2310d8fb2e05aef343ea24166afb9fd

[27] Refactor child Text nodes to a new concept · whatwg/html@0dd609f ( 版) https://github.com/whatwg/html/commit/0dd609fddc08dab337d24da874c787e51e851efc

[30] Formalize custom element reactions · whatwg/html@27aa7bc ( 版) https://github.com/whatwg/html/commit/27aa7bc4fa6f168654a8c858f0773e611f679b39

[31] Add child text content and its change steps (domenic著, ) https://github.com/whatwg/dom/commit/93db3408c360a958c2f1c00fbb99bf6c5d6fa5b2

[36] Add child text content and its change steps by domenic · Pull Request #466 · whatwg/dom () https://github.com/whatwg/dom/pull/466

[38] Update textarea textContent/defaultValue/value interaction (domenic著, ) https://github.com/whatwg/html/commit/5afbba1cf62ee01bc6af3fd220d01f3f7591a0fc

[39] "When the textarea element's textContent IDL attribute changes" · Issue #2750 · whatwg/html () https://github.com/whatwg/html/issues/2750

[40] Textarea defaultValue handling doesn't really match UAs (who don't match each other) when there are child elements · Issue #2752 · whatwg/html () https://github.com/whatwg/html/issues/2752

[42] Update textarea textContent/defaultValue/value interaction by domenic · Pull Request #2766 · whatwg/html () https://github.com/whatwg/html/pull/2766

[44] Improve <style> and <script> processing and conformance (domenic著, ) https://github.com/whatwg/html/commit/9c612ac8641b5174849a2d3cb924fe662a8d3a09

[45] <style> should use child text content changed steps · Issue #2996 · whatwg/html () https://github.com/whatwg/html/issues/2996

[46] Improve <style> and <script> processing and conformance by domenic · Pull Request #3024 · whatwg/html () https://github.com/whatwg/html/pull/3024

[47] Editorial: use "child text content" in the <script> processing model (ankurkaushal著, ) https://github.com/whatwg/html/commit/58286f7078b3aceee060ed6d3635ab8749a77238

[48] <script> processing model should use child text content, not the text IDL attribute · Issue #3420 · whatwg/html () https://github.com/whatwg/html/issues/3420

[49] #3420: Editorial fix for the <script> processing model. by ankurkaushal · Pull Request #3421 · whatwg/html () https://github.com/whatwg/html/pull/3421

[50] Amend bad link to the child text content change steps (alexnoz著, ) https://github.com/whatwg/html/commit/8427925e026fa96cb61e7290f18a168d4ee9e183

[51] Bad link to "child text content change steps" in "The `style` element" · Issue #3384 · whatwg/html () https://github.com/whatwg/html/issues/3384

[52] Amend bad link to the child text content change steps by alexnoz · Pull Request #3422 · whatwg/html () https://github.com/whatwg/html/pull/3422

[53] Use "child text content" to check if a <script> is empty (domenic著, ) https://github.com/whatwg/html/commit/1d64c41e811aab5831be474355bd346c9eaf2874

[54] <script> processing model with various children · Issue #3419 · whatwg/html () https://github.com/whatwg/html/issues/3419

[55] Use "child text content" to check if a <script> is empty by domenic · Pull Request #3451 · whatwg/html () https://github.com/whatwg/html/pull/3451

[56] Stop using textContent in normative text (annevk著, ) https://github.com/whatwg/html/commit/ec860d872de3712277242655562a4d2a1325592a

[57] Align with DOM's children changed steps (annevk, , ) https://github.com/whatwg/html/commit/928f862788e5d1d3fef905fd36bb55ea1939b0c1