diff --git a/dom-merge-conflict/tasks/buttons-and-counter/src/app.js b/dom-merge-conflict/tasks/buttons-and-counter/src/app.js index af608eb..eec1e72 100644 --- a/dom-merge-conflict/tasks/buttons-and-counter/src/app.js +++ b/dom-merge-conflict/tasks/buttons-and-counter/src/app.js @@ -12,20 +12,4 @@ export function App() {
A simple counter. Press increment to increase the count by one.
`; - body.appendChild(header); - - const main = document.createElement("main"); - main.innerHTML = ` -0
- - `; - body.appendChild(main); - - const button = body.querySelector("#increment"); - const counter = body.querySelector("#counter"); - button.addEventListener("click", () => { - increment(counter); - }); - - return body; -} + diff --git a/dom-merge-conflict/tasks/buttons-and-counter/src/header.js b/dom-merge-conflict/tasks/buttons-and-counter/src/header.js new file mode 100644 index 0000000..8c99f16 --- /dev/null +++ b/dom-merge-conflict/tasks/buttons-and-counter/src/header.js @@ -0,0 +1,14 @@ +function increment(node) { + let current = node.textContent; + node.textContent = Number(current) + 1; +} + +export function App() { + const body = document.createElement("body"); + + const header = document.createElement("header"); + header.innerHTML = ` +A simple counter. Press increment to increase the count by one.
+ `; + diff --git a/dom-merge-conflict/tasks/buttons-and-counter/src/main.js b/dom-merge-conflict/tasks/buttons-and-counter/src/main.js new file mode 100644 index 0000000..243ed7d --- /dev/null +++ b/dom-merge-conflict/tasks/buttons-and-counter/src/main.js @@ -0,0 +1,17 @@ +body.appendChild(header); + + const main = document.createElement("main"); + main.innerHTML = ` +0
+ + `; + body.appendChild(main); + + const button = body.querySelector("#increment"); + const counter = body.querySelector("#counter"); + button.addEventListener("click", () => { + increment(counter); + }); + + return body; +} \ No newline at end of file