hyperapp: V2 not working well for checkbox
V2 does not update input.checked
attribute. Is there a mistake in my code?
Example code: https://codesandbox.io/embed/k5jk439x7o
code:
import * as v2 from "./hyperapp-v2";
import * as v1 from "hyperapp";
const SetCheck = (state, { checked }, ev) => {
ev.preventDefault();
return { ...state, checked: checked };
};
v2.app({
init: { checked: false },
view: state =>
v2.h("div", {}, [
v2.h("input", {
type: "checkbox",
checked: state.checked,
onClick: [SetCheck, { checked: !state.checked }]
}),
state.checked ? "checked" : "unchecked"
]),
container: document.getElementById("v2")
});
v1.app(
{ checked: false },
{
setCheck: ({ checked, ev }) => state => {
ev.preventDefault();
return { checked: checked };
}
},
(state, actions) =>
v1.h("div", {}, [
v1.h("input", {
type: "checkbox",
checked: state.checked,
onclick: ev => actions.setCheck({ checked: !state.checked, ev })
}),
state.checked ? "checked" : "unchecked"
]),
document.getElementById("v1")
);
html:
v2
<div id="v2"></div>
v1
<div id="v1"></div>
Thank you for reading
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 22 (18 by maintainers)
@frenzzy In this instance V2 behaves like your fiddle, so, more like the native DOM, whereas V1 does not.
Can you make it works with native DOM? http://jsfiddle.net/d2hqmct7/