|
10 | 10 | 'use strict';
|
11 | 11 |
|
12 | 12 | // Set by `yarn test-fire`.
|
13 |
| -const {disableInputAttributeSyncing} = require('shared/ReactFeatureFlags'); |
| 13 | +const { |
| 14 | + enableCustomElementPropertySupport, |
| 15 | + disableInputAttributeSyncing, |
| 16 | +} = require('shared/ReactFeatureFlags'); |
14 | 17 |
|
15 | 18 | describe('DOMPropertyOperations', () => {
|
16 | 19 | let React;
|
@@ -256,8 +259,12 @@ describe('DOMPropertyOperations', () => {
|
256 | 259 | expect(customElement.getAttribute('onstring')).toBe('hello');
|
257 | 260 | expect(customElement.getAttribute('onobj')).toBe('[object Object]');
|
258 | 261 | expect(customElement.getAttribute('onarray')).toBe('one,two');
|
259 |
| - expect(customElement.getAttribute('ontrue')).toBe('true'); |
260 |
| - expect(customElement.getAttribute('onfalse')).toBe('false'); |
| 262 | + expect(customElement.getAttribute('ontrue')).toBe( |
| 263 | + enableCustomElementPropertySupport ? '' : 'true', |
| 264 | + ); |
| 265 | + expect(customElement.getAttribute('onfalse')).toBe( |
| 266 | + enableCustomElementPropertySupport ? null : 'false', |
| 267 | + ); |
261 | 268 |
|
262 | 269 | // Dispatch the corresponding event names to make sure that nothing crashes.
|
263 | 270 | customElement.dispatchEvent(new Event('string'));
|
@@ -959,6 +966,21 @@ describe('DOMPropertyOperations', () => {
|
959 | 966 | expect(customElement.foo).toBe(null);
|
960 | 967 | });
|
961 | 968 |
|
| 969 | + // @gate enableCustomElementPropertySupport |
| 970 | + it('boolean props should not be stringified in attributes', () => { |
| 971 | + const container = document.createElement('div'); |
| 972 | + document.body.appendChild(container); |
| 973 | + ReactDOM.render(<my-custom-element foo={true} />, container); |
| 974 | + const customElement = container.querySelector('my-custom-element'); |
| 975 | + |
| 976 | + expect(customElement.getAttribute('foo')).toBe(''); |
| 977 | + |
| 978 | + // true => false |
| 979 | + ReactDOM.render(<my-custom-element foo={false} />, container); |
| 980 | + |
| 981 | + expect(customElement.getAttribute('foo')).toBe(null); |
| 982 | + }); |
| 983 | + |
962 | 984 | // @gate enableCustomElementPropertySupport
|
963 | 985 | it('custom element custom event handlers assign multiple types', () => {
|
964 | 986 | const container = document.createElement('div');
|
|
0 commit comments