From b409b20c367eb88136d48271c2072782d4aea1e0 Mon Sep 17 00:00:00 2001 From: John Robinson Date: Tue, 12 Mar 2019 09:04:23 -0400 Subject: [PATCH] render immediately when first connected --- sm-element.js | 2 ++ src/sm-element.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/sm-element.js b/sm-element.js index 9f9202e..10aec68 100644 --- a/sm-element.js +++ b/sm-element.js @@ -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 diff --git a/src/sm-element.ts b/src/sm-element.ts index 3abbcb3..feb158a 100644 --- a/src/sm-element.ts +++ b/src/sm-element.ts @@ -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() {