diff --git a/src/preview/PreviewView.js b/src/preview/PreviewView.js index ecc95f1..2cee062 100644 --- a/src/preview/PreviewView.js +++ b/src/preview/PreviewView.js @@ -20,13 +20,15 @@ import {ClientView} from "../open/ClientView.js"; export class PreviewView extends TemplateView { render(t, vm) { - return t.mapView(vm => vm.loading, loading => loading ? new LoadingPreviewView(vm) : new LoadedPreviewView(vm)); + return t.div({className: "PreviewView"}, t.mapView(vm => vm.loading, loading => { + return loading ? new LoadingPreviewView(vm) : new LoadedPreviewView(vm); + })); } } class LoadingPreviewView extends TemplateView { render(t, vm) { - return t.div({className: "PreviewView"}, [ + return t.div([ t.div({className: "avatarContainer"}, t.div({className: "avatar loading"}, t.div({className: "spinner"}))), t.h1(vm => vm.name), t.p({className: "identifier placeholder"}), @@ -42,7 +44,7 @@ class LoadingPreviewView extends TemplateView { class LoadedPreviewView extends TemplateView { render(t, vm) { - return t.div({className: "PreviewView"}, [ + return t.div([ t.div({className: "avatarContainer"}, t.img({className: "avatar", src: vm => vm.avatarUrl})), t.h1(vm => vm.name), t.p({className: {identifier: true, hidden: vm => !vm.identifier}}, vm => vm.identifier), diff --git a/src/utils/TemplateView.js b/src/utils/TemplateView.js index 1617d6a..c414c37 100644 --- a/src/utils/TemplateView.js +++ b/src/utils/TemplateView.js @@ -238,6 +238,8 @@ class TemplateBuilder { const newNode = renderNode(node); if (node.parentNode) { node.parentNode.replaceChild(newNode, node); + } else { + console.warn("Could not update parent of node binding"); } node = newNode; } @@ -342,4 +344,4 @@ for (const [ns, tags] of Object.entries(TAG_NAMES)) { return this.elNS(ns, tag, attributes, children); }; } -} \ No newline at end of file +}