Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aralroca committed Oct 27, 2023
1 parent b3fdc6c commit 146a7b2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions www/posts/htmx-and-web-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ export default class Counter extends BrisaElement {
inc.addEventListener('click', () => count.value++)

const countEl = c('span');
$effect(() => countEl.textContent = ` ${name.value} ${count.value} `);
$effect(() => countEl.textContent = ` ${name.value} ${count.value.toString()} `);

const dec = c('button');
dec.textContent = '-';
Expand All @@ -601,6 +601,7 @@ export default class Counter extends BrisaElement {
const p = c('p');
p.appendChild(inc);
p.appendChild(countEl);
p.appendChild(c('slot')); // children
p.appendChild(dec);

this.els = [p];
Expand Down Expand Up @@ -646,8 +647,9 @@ class BrisaElement extends HTMLElement {
this.p[attr] = ctx.$state(this.getAttribute(attr));
};

const shadowRoot = this.attachShadow({ mode: "open" });
this.r(this.p, ctx)
this.els.forEach((el) => this.appendChild(el));
this.els.forEach((el) => shadowRoot.appendChild(el));
}

attributeChangedCallback(name, oldValue, newValue) {
Expand Down

0 comments on commit 146a7b2

Please sign in to comment.