Skip to content

Commit 51cf127

Browse files
awearymadeinfree
authored andcommitted
Remove empty value for boolean attributes in SSR (facebook#11708)
1 parent e3c7b88 commit 51cf127

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

packages/react-dom/src/__tests__/ReactDOMSelect-test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,9 @@ describe('ReactDOMSelect', () => {
440440
</select>
441441
);
442442
var markup = ReactDOMServer.renderToString(stub);
443-
expect(markup).toContain('<option selected="" value="giraffe"');
444-
expect(markup).not.toContain('<option selected="" value="monkey"');
445-
expect(markup).not.toContain('<option selected="" value="gorilla"');
443+
expect(markup).toContain('<option selected value="giraffe"');
444+
expect(markup).not.toContain('<option selected value="monkey"');
445+
expect(markup).not.toContain('<option selected value="gorilla"');
446446
});
447447

448448
it('should support server-side rendering with defaultValue', () => {
@@ -454,9 +454,9 @@ describe('ReactDOMSelect', () => {
454454
</select>
455455
);
456456
var markup = ReactDOMServer.renderToString(stub);
457-
expect(markup).toContain('<option selected="" value="giraffe"');
458-
expect(markup).not.toContain('<option selected="" value="monkey"');
459-
expect(markup).not.toContain('<option selected="" value="gorilla"');
457+
expect(markup).toContain('<option selected value="giraffe"');
458+
expect(markup).not.toContain('<option selected value="monkey"');
459+
expect(markup).not.toContain('<option selected value="gorilla"');
460460
});
461461

462462
it('should support server-side rendering with multiple', () => {
@@ -468,9 +468,9 @@ describe('ReactDOMSelect', () => {
468468
</select>
469469
);
470470
var markup = ReactDOMServer.renderToString(stub);
471-
expect(markup).toContain('<option selected="" value="giraffe"');
472-
expect(markup).toContain('<option selected="" value="gorilla"');
473-
expect(markup).not.toContain('<option selected="" value="monkey"');
471+
expect(markup).toContain('<option selected value="giraffe"');
472+
expect(markup).toContain('<option selected value="gorilla"');
473+
expect(markup).not.toContain('<option selected value="monkey"');
474474
});
475475

476476
it('should not control defaultValue if readding options', () => {

packages/react-dom/src/server/DOMMarkupOperations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function createMarkupForProperty(name, value) {
9090
propertyInfo.hasBooleanValue ||
9191
(propertyInfo.hasOverloadedBooleanValue && value === true)
9292
) {
93-
return attributeName + '=""';
93+
return attributeName;
9494
} else if (
9595
typeof value !== 'boolean' ||
9696
shouldAttributeAcceptBooleanValue(name)

0 commit comments

Comments
 (0)