Skip to content

Commit ec63def

Browse files
committed
Add guard around commitTextValue to avoid IE9 undo bug
This commit fixes a case where IE9 raises an exception if modifying a detached text node.
1 parent fa8e678 commit ec63def

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

fixtures/dom/src/components/fixtures/number-inputs/NumberTestCase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const React = window.React;
55
class NumberTestCase extends React.Component {
66
state = {value: ''};
77
onChange = event => {
8-
const parsed = parseFloat(event.target.value, 10);
8+
const parsed = parseFloat(event.currentTarget.value, 10);
99
const value = isNaN(parsed) ? '' : parsed;
1010

1111
this.setState({value});

fixtures/dom/src/tags.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const TAGS_CACHE_KEY = '@react-dom-fixtures/tags';
1515
* can manually load it by editing the URL (`?version={whatever}`)
1616
*/
1717
const fallbackTags = [
18+
'16.3.0',
19+
'16.2.0',
20+
'16.1.1',
1821
'15.4.2',
1922
'15.3.2',
2023
'15.2.1',

packages/react-dom/src/client/ReactDOM.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,12 @@ const DOMRenderer = ReactFiberReconciler({
736736
oldText: string,
737737
newText: string,
738738
): void {
739-
textInstance.nodeValue = newText;
739+
// IE9 will raise an exception if modifying a detached text node
740+
// eslint-disable-next-line
741+
// https://connect.microsoft.com/IE/feedbackdetail/view/944330/invalid-argument-error-when-changing-nodevalue-of-a-text-node-removed-by-setting-innerhtml-on-an-ancestor
742+
if (textInstance.parentNode) {
743+
textInstance.nodeValue = newText;
744+
}
740745
},
741746

742747
appendChild(

0 commit comments

Comments
 (0)