Skip to content

Commit

Permalink
Remove empty value for boolean attributes in SSR (facebook#11708)
Browse files Browse the repository at this point in the history
  • Loading branch information
aweary authored and madeinfree committed Nov 30, 2017
1 parent e3c7b88 commit 51cf127
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions packages/react-dom/src/__tests__/ReactDOMSelect-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ describe('ReactDOMSelect', () => {
</select>
);
var markup = ReactDOMServer.renderToString(stub);
expect(markup).toContain('<option selected="" value="giraffe"');
expect(markup).not.toContain('<option selected="" value="monkey"');
expect(markup).not.toContain('<option selected="" value="gorilla"');
expect(markup).toContain('<option selected value="giraffe"');
expect(markup).not.toContain('<option selected value="monkey"');
expect(markup).not.toContain('<option selected value="gorilla"');
});

it('should support server-side rendering with defaultValue', () => {
Expand All @@ -454,9 +454,9 @@ describe('ReactDOMSelect', () => {
</select>
);
var markup = ReactDOMServer.renderToString(stub);
expect(markup).toContain('<option selected="" value="giraffe"');
expect(markup).not.toContain('<option selected="" value="monkey"');
expect(markup).not.toContain('<option selected="" value="gorilla"');
expect(markup).toContain('<option selected value="giraffe"');
expect(markup).not.toContain('<option selected value="monkey"');
expect(markup).not.toContain('<option selected value="gorilla"');
});

it('should support server-side rendering with multiple', () => {
Expand All @@ -468,9 +468,9 @@ describe('ReactDOMSelect', () => {
</select>
);
var markup = ReactDOMServer.renderToString(stub);
expect(markup).toContain('<option selected="" value="giraffe"');
expect(markup).toContain('<option selected="" value="gorilla"');
expect(markup).not.toContain('<option selected="" value="monkey"');
expect(markup).toContain('<option selected value="giraffe"');
expect(markup).toContain('<option selected value="gorilla"');
expect(markup).not.toContain('<option selected value="monkey"');
});

it('should not control defaultValue if readding options', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/server/DOMMarkupOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function createMarkupForProperty(name, value) {
propertyInfo.hasBooleanValue ||
(propertyInfo.hasOverloadedBooleanValue && value === true)
) {
return attributeName + '=""';
return attributeName;
} else if (
typeof value !== 'boolean' ||
shouldAttributeAcceptBooleanValue(name)
Expand Down

0 comments on commit 51cf127

Please sign in to comment.