Polymer / polymer

Our original Web Component library.
https://polymer-library.polymer-project.org/
BSD 3-Clause "New" or "Revised" License
22.05k stars 2.02k forks source link

Workaround bindings to textarea.placeholder in IE #5577

Closed dfreedm closed 5 years ago

dfreedm commented 5 years ago

Textareas have a very weird bug in IE, where the text of the placeholder is copied to the content of the textarea when set.

This a creates two bugs:

  1. An unintended binding is made to the textContent of the textarea's text child node, meaning updates to the placeholder will be an unnecessary binding process in the best case, or an exception thrown when updating the text child node in the worst case.
  2. When legacyOptimizations is enabled, the child node of the text area is removed when the binding for placeholder is processed and removed, leaving a binding to a null node, and throwing exceptions.

Therefore, when we detect this placeholder behavior, we will remove the textnode before template processing, preventing both bugs.

sorvell commented 5 years ago

For the second problem, this is caused because when textarea has a placeholder in IE, it generates textContent of the same value. Polymer sees this and creates a binding to the textarea.textContent. Polymer removes the placeholder attribute and on IE this removes the textContent of the textarea. Therefore, when the template is stamped, there is no node in the textarea and Polymer cannot find the node to which the textarea.textContent binding should point.