diff --git a/src/js.js b/src/js.js index 8090b42..945b6c7 100644 --- a/src/js.js +++ b/src/js.js @@ -175,6 +175,19 @@ function JSXAddFixedWrapper(ptr, cb, $if) { }) } +// returns a function that sets a reference +// the currying is a small optimization +const curryset = ptr => val =>{ + let next = ptr[PROXY]; + let steps = ptr[STEPS]; + let i =0; + for (;i elm.value = value); - elm.addEventListener("change", () => { - ptr[PROXY][ptr[STEPS][0]] = elm.value; - }) + elm.addEventListener("change", () => set(elm.value)) } else if (propname == "checked") { handle(ptr, value => elm.checked = value); - elm.addEventListener("click", () => { - ptr[PROXY][ptr[STEPS][0]] = elm.checked; - }) + elm.addEventListener("click", () => set(elm.checked)) } delete props[name]; } @@ -352,13 +363,8 @@ function JSXAddChild(child, cb) { // Where properties are assigned to elements, and where the *non-reactive* syntax sugar goes function JSXAddAttributes(elm, name, prop) { - if (typeof prop === "function" && name === "mount") { - window.$el = elm; - prop(elm); - return; - } - - if (typeof prop === "function" && name.startsWith("on:")) { + if (name.startsWith("on:")) { + assert(typeof prop === "function", "on: requires a function"); const names = name.substring(3); for (const name of names.split("$")) { elm.addEventListener(name, (...args) => {