Hi,
I have noticed a strange behavior trying to set a two-way binding with a select element. The component:
<can-component tag="pmo-dummy">
<view>
<select {($value)}="selected">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
</view>
<script type="view-model">
import DefineMap from 'can-define/map/';
export default DefineMap.extend({
selected: {
value: 3
}
});
</script>
</can-component>
Then i start the done-serve in develop mode, but as soon i open the app in browser it throws an error:
Potentially unhandled rejection [1] TypeError: attrValue.replace is not a function
at HTMLSerializer.escapeAttrValue (/home/goyo/Documents/pmo/node_modules/can-simple-dom/dist/cjs/simple-dom/html-serializer.js:26:22)
at HTMLSerializer.attr (/home/goyo/Documents/pmo/node_modules/can-simple-dom/dist/cjs/simple-dom/html-serializer.js:45:46)
at HTMLSerializer.attributes (/home/goyo/Documents/pmo/node_modules/can-simple-dom/dist/cjs/simple-dom/html-serializer.js:21:24)
at HTMLSerializer.openTag (/home/goyo/Documents/pmo/node_modules/can-simple-dom/dist/cjs/simple-dom/html-serializer.js:10:56)
at HTMLSerializer.serialize (/home/goyo/Documents/pmo/node_modules/can-simple-dom/dist/cjs/simple-dom/html-serializer.js:85:24)
at HTMLSerializer.serialize (/home/goyo/Documents/pmo/node_modules/can-simple-dom/dist/cjs/simple-dom/html-serializer.js:99:28)
at HTMLSerializer.serialize (/home/goyo/Documents/pmo/node_modules/can-simple-dom/dist/cjs/simple-dom/html-serializer.js:99:28)
at HTMLSerializer.serialize (/home/goyo/Documents/pmo/node_modules/can-simple-dom/dist/cjs/simple-dom/html-serializer.js:99:28)
at HTMLSerializer.serialize (/home/goyo/Documents/pmo/node_modules/can-simple-dom/dist/cjs/simple-dom/html-serializer.js:99:28)
at Element.get [as innerHTML] (/home/goyo/Documents/pmo/node_modules/can-simple-dom/dist/cjs/simple-dom/document/element.js:165:57)
If i remove the binding from the select and start the server again everything works fine. Without stopping the server, if i add the binding to the select element and save the file, the live reload assigns correctly the value to the select without throwing any error, but if i stop the server and start it again, the error is throwed. It only happens with the select element, i tried with input element and it works perfectly. BUT, if i set selected to 5 or any other value not listed in the options select, the error is not throwed!
I think i has something to do with the SSR, because if i start the serve in static mode (done-serve --static) everything’s works correctly.
Im using canjs version 3.0, nodejs version 6.10.3. Im stuck with this since 2 days, any help would be really appreciated. THANKS!