Skip to content
Open
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
42 changes: 21 additions & 21 deletions JavaScript/3-abstraction.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@
<html>
<head>
<script type="application/javascript">
// Case 3: Visual component

// Case 3: Visul component
class PageCaption extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
this.clicked = false;
}

class PageCaption extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.clicked = false;
}

connectedCallback() {
const html = `<h1>Marcus</h1><button type="button">Ave Marcus!</button>`;
this.shadowRoot.innerHTML = html;
this.shadowRoot.querySelector('button').addEventListener('click', () => {
if (!this.clicked) {
this.clicked = true;
const html = `<h1>Ave Marcus Aurelius!</h1>`;
this.shadowRoot.innerHTML = html;
connectedCallback() {
const html = `<h1>Marcus</h1><button type="button">Ave Marcus!</button>`;
this.shadowRoot.innerHTML = html;
this.shadowRoot
.querySelector("button")
.addEventListener("click", () => {
if (!this.clicked) {
this.clicked = true;
const html = `<h1>Ave Marcus Aurelius!</h1>`;
this.shadowRoot.innerHTML = html;
}
});
}
}
});
}
}

window.customElements.define('page-caption', PageCaption);

window.customElements.define("page-caption", PageCaption);
</script>
</head>
<body>
Expand Down