Skip to content

Instantly share code, notes, and snippets.

@yelouafi
Last active August 29, 2015 14:25
Show Gist options
  • Save yelouafi/36dca34a3f76efe225fb to your computer and use it in GitHub Desktop.
Save yelouafi/36dca34a3f76efe225fb to your computer and use it in GitHub Desktop.
function view(name) {
return h('div', [
h('input', {
props: { type: 'text', placeholder: 'Type your name' },
on : { input: update }
}),
h('hr'),
h('div', 'Hello ' + name)
]);
}
var oldVnode = document.getElementById('placeholder');
function update(event) {
const newVnode = view(event.target.value);
oldVnode = patch(oldVnode, newVnode);
}
oldVnode = patch(oldVnode, view(''));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment