Created
April 1, 2018 14:52
-
-
Save alexzuza/4c27142fc6a75729bd443743de7d7c92 to your computer and use it in GitHub Desktop.
IDOM test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function render(data) { | |
elementOpen('h1'); | |
{ | |
text('Hello, ' + data.user) | |
} | |
elementClose('h1'); | |
elementOpen('ul') | |
{ | |
elementOpen('li'); | |
{ | |
text('Counter: ') | |
elementOpen('span'); | |
{ | |
text(data.counter); | |
} | |
elementClose('span'); | |
} | |
elementClose('li'); | |
} | |
elementClose('ul'); | |
} | |
document.querySelector('button').addEventListener('click', () => { | |
data.counter ++; | |
patch(document.body, render, data); | |
}); | |
document.querySelector('input').addEventListener('input', (e) => { | |
data.user = e.target.value; | |
patch(document.body, render, data); | |
}); | |
const data = { | |
user: 'Alexey', | |
counter: 1 | |
}; | |
patch(document.body, render, data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment