9
9
10
10
'use strict' ;
11
11
12
+ // Set by `yarn test-fire`.
13
+ const { disableInputAttributeSyncing} = require ( 'shared/ReactFeatureFlags' ) ;
14
+
12
15
describe ( 'DOMPropertyOperations' , ( ) => {
13
16
let React ;
14
17
let ReactDOM ;
@@ -80,7 +83,11 @@ describe('DOMPropertyOperations', () => {
80
83
it ( 'should not remove empty attributes for special input properties' , ( ) => {
81
84
const container = document . createElement ( 'div' ) ;
82
85
ReactDOM . render ( < input value = "" onChange = { ( ) => { } } /> , container ) ;
83
- expect ( container . firstChild . getAttribute ( 'value' ) ) . toBe ( '' ) ;
86
+ if ( disableInputAttributeSyncing ) {
87
+ expect ( container . firstChild . hasAttribute ( 'value' ) ) . toBe ( false ) ;
88
+ } else {
89
+ expect ( container . firstChild . getAttribute ( 'value' ) ) . toBe ( '' ) ;
90
+ }
84
91
expect ( container . firstChild . value ) . toBe ( '' ) ;
85
92
} ) ;
86
93
@@ -165,7 +172,11 @@ describe('DOMPropertyOperations', () => {
165
172
< input type = "text" value = "foo" onChange = { function ( ) { } } /> ,
166
173
container ,
167
174
) ;
168
- expect ( container . firstChild . getAttribute ( 'value' ) ) . toBe ( 'foo' ) ;
175
+ if ( disableInputAttributeSyncing ) {
176
+ expect ( container . firstChild . hasAttribute ( 'value' ) ) . toBe ( false ) ;
177
+ } else {
178
+ expect ( container . firstChild . getAttribute ( 'value' ) ) . toBe ( 'foo' ) ;
179
+ }
169
180
expect ( container . firstChild . value ) . toBe ( 'foo' ) ;
170
181
expect ( ( ) =>
171
182
ReactDOM . render (
@@ -175,7 +186,11 @@ describe('DOMPropertyOperations', () => {
175
186
) . toWarnDev (
176
187
'A component is changing a controlled input of type text to be uncontrolled' ,
177
188
) ;
178
- expect ( container . firstChild . getAttribute ( 'value' ) ) . toBe ( 'foo' ) ;
189
+ if ( disableInputAttributeSyncing ) {
190
+ expect ( container . firstChild . hasAttribute ( 'value' ) ) . toBe ( false ) ;
191
+ } else {
192
+ expect ( container . firstChild . getAttribute ( 'value' ) ) . toBe ( 'foo' ) ;
193
+ }
179
194
expect ( container . firstChild . value ) . toBe ( 'foo' ) ;
180
195
} ) ;
181
196
0 commit comments