Skip to content

Commit f1e275e

Browse files
Fix select value not passed through components
1 parent 542ea41 commit f1e275e

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
6565
getChildren(children, vnode.props.children);
6666

6767
for (let i = 0; i < children.length; i++) {
68-
rendered += renderToString(children[i], context, opts, opts.shallowHighOrder!==false, isSvgMode);
68+
rendered += renderToString(children[i], context, opts, opts.shallowHighOrder!==false, isSvgMode, selectValue);
6969
}
7070
return rendered;
7171
}
@@ -97,7 +97,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
9797
context = assign(assign({}, context), c.getChildContext());
9898
}
9999

100-
return renderToString(rendered, context, opts, opts.shallowHighOrder!==false);
100+
return renderToString(rendered, context, opts, opts.shallowHighOrder!==false, isSvgMode, selectValue);
101101
}
102102
}
103103

test/render.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,4 +740,33 @@ describe('render', () => {
740740
);
741741
expect(res).to.equal('<select><option value="A">A</option><option selected value="B">B</option></select>');
742742
});
743+
744+
it('should render select value on option with a Fragment', () => {
745+
let res = render(
746+
<select value="B">
747+
<Fragment>
748+
<option value="A">A</option>
749+
<option value="B">B</option>
750+
</Fragment>
751+
</select>
752+
);
753+
expect(res).to.equal('<select><option value="A">A</option><option selected value="B">B</option></select>');
754+
});
755+
756+
it('should render select value on option through a component', () => {
757+
function Foo() {
758+
return (
759+
<optgroup label="foo">
760+
<option value="A">A</option>
761+
<option value="B">B</option>
762+
</optgroup>
763+
);
764+
}
765+
let res = render(
766+
<select value="B">
767+
<Foo />
768+
</select>
769+
);
770+
expect(res).to.equal('<select><optgroup label="foo"><option value="A">A</option><option selected value="B">B</option></optgroup></select>');
771+
});
743772
});

0 commit comments

Comments
 (0)