From 5afbba1cf62ee01bc6af3fd220d01f3f7591a0fc Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Thu, 15 Jun 2017 16:46:10 -0400 Subject: [PATCH] Update textarea textContent/defaultValue/value interaction This fixes #2752, where it was revealed that most browsers do not care about the textContent of a textarea, but instead about its child text content. That is, if you use the DOM APIs to insert a child element into the textarea element, its text does not show up for editing or as part of the value and defaultValue properties (even though it shows up in textContent). This moves to a model where textareas operate entirely on the child text content. This matches Blink and Gecko, and somewhat matches WebKit. This also fixes #2750, by using the newly-introduced "child text content change steps" hook introduced to DOM in https://github.com/whatwg/dom/pull/466. --- source | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/source b/source index b3f8e1b1f56..265d6979ac3 100644 --- a/source +++ b/source @@ -1971,10 +1971,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute or string, means that the length of the text is zero (i.e., not even containing controls or U+0020 SPACE).

-

An element's child text content is the concatenation of the data of all the Text nodes that are children of the - element (ignoring any other nodes such as comments or elements), in tree order.

-

A node A is inserted into a node B when the insertion steps are invoked with A as the argument and A's new parent is B. Similarly, a The pre-insert, insert, append, replace, replace all, remove, and adopt algorithms for nodes

  • The change, append, remove, replace, and set value algorithms for attributes
  • The insertion steps, - removing steps, and - adopting steps hooks
  • + removing steps, + adopting steps, and + child text content change steps hooks
  • The attribute list concept
  • The data of a text node
  • +
  • The child text content of a node
  • Event interface
  • EventTarget interface
  • The activation behavior hook
  • @@ -50481,15 +50479,15 @@ interface HTMLTextAreaElement : HTMLElement { elements must propagate the raw value and dirty value flag from the node being cloned to the copy.

    -

    When the textarea element's textContent IDL attribute changes value, - if the element's dirty value flag is false, then the - element's raw value must be set to the value of - the element's textContent IDL attribute.

    +

    The child text content change steps for textarea elements must, if + the element's dirty value flag is false, set the element's + raw value to its child text + content.

    The reset algorithm for textarea elements is to set the dirty value flag back to false, and - set the raw value of element to the value of the - element's textContent IDL attribute.

    + set the raw value of element to its child + text content.

    When a textarea element is popped off the stack of open elements of an HTML parser or XML parser, then the user agent must invoke the @@ -50750,8 +50748,9 @@ interface HTMLTextAreaElement : HTMLElement {

    The type IDL attribute must return the value "textarea".

    -

    The defaultValue IDL attribute must - act like the element's textContent IDL attribute.

    +

    The defaultValue IDL attribute must, + on getting, return the element's child text content. On setting, it must act as the + setter for the element's textContent IDL attribute.

    The value IDL attribute must, on getting, return the element's API value. On setting, it must