Skip to content

Commit

Permalink
render immediately when first connected
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinson01 committed Mar 12, 2019
1 parent 51f8b48 commit b409b20
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sm-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class SMElement extends HTMLElement {
if (this.getAttribute('state') !== this.__state) {
this.setAttribute('state', this.__state);
}
// render immediately the first time
this.render(this.data);
}
disconnectedCallback() {
// nothing to do here. provided for subclasses calling super.disconnectedCallback
Expand Down
3 changes: 3 additions & 0 deletions src/sm-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ class SMElement extends HTMLElement {
if (this.getAttribute('state') !== this.__state) {
this.setAttribute('state', this.__state);
}
// render immediately the first time, so that elements
// can be accessed in connectedCallback()
this.render(this.data);
}

protected disconnectedCallback() {
Expand Down

0 comments on commit b409b20

Please sign in to comment.