Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions dom-merge-conflict/tasks/buttons-and-counter/src/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//increments the number in a node's text
import { header } from "./header.js";
import { main } from "./main.js";

function increment(node) {
let current = node.textContent;
node.textContent = Number(current) + 1;
Expand All @@ -7,20 +10,13 @@ function increment(node) {
export function App() {
const body = document.createElement("body");

const header = document.createElement("header");
header.innerHTML = `
<h1>Number Counter</h1>
<p>A simple counter. Press increment to increase the count by one.</p>
`;

body.appendChild(header);

const main = document.createElement("main");
main.innerHTML = `
<p id="counter" data-testid="counter">0</p>
<button id="increment">Increment</button>
`;

body.appendChild(main);


const button = body.querySelector("#increment");
const counter = body.querySelector("#counter");
button.addEventListener("click", () => {
Expand Down
7 changes: 7 additions & 0 deletions dom-merge-conflict/tasks/buttons-and-counter/src/header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function header() {

const header = document.createElement("header");
header.innerHTML = `
<h1>Number Counter</h1>
<p>A simple counter. Press increment to increase the count by one.</p>
`;}
6 changes: 6 additions & 0 deletions dom-merge-conflict/tasks/buttons-and-counter/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function main() {
const main = document.createElement("main");
main.innerHTML = `
<p id="counter" data-testid="counter">0</p>
<button id="increment">Increment</button>
`;}