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

This commit is contained in:
Brandon Dail 2017-11-29 09:59:56 -08:00 committed by GitHub
parent 3e64b18540
commit e0c3113743
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -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', () => {
@ -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', () => {
@ -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', () => {

View File

@ -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)