From d038f7c1a1e30047ddd5f75de6da645d7d287927 Mon Sep 17 00:00:00 2001 From: MrOtherGuy Date: Sat, 7 May 2022 18:58:38 +0300 Subject: [PATCH] Add early return when determining content to load. --- html_resources/code-block/code-block.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/html_resources/code-block/code-block.js b/html_resources/code-block/code-block.js index 73c3095..3cf0f74 100644 --- a/html_resources/code-block/code-block.js +++ b/html_resources/code-block/code-block.js @@ -21,7 +21,11 @@ class CodeBlock extends HTMLElement{ } determineAndLoadContent(){ - CodeBlock.getSource(this.src) + const src = this.src; + if(!src){ + return + } + CodeBlock.getSource(src) .then( (data) => this.consumeData(data,CodeBlock.InsertMode.Replace), (e) => this.consumeData({content:this.textContent},CodeBlock.InsertMode.Replace) @@ -313,7 +317,10 @@ class CodeBlock extends HTMLElement{ } get codeBox(){ - return this.shadowRoot.querySelector("tbody"); + if(!this._codeBox){ + this._codeBox = this.shadowRoot.querySelector("tbody"); + } + return this._codeBox; } get value(){ return this.codeBox.textContent