Skip to content

Revert "Remove empty value for boolean attributes in SSR (#11708)" #11798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
);
const 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>
);
const 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>
);
const 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