Add early return when determining content to load.

This commit is contained in:
MrOtherGuy 2022-05-07 18:58:38 +03:00
parent 7d083242c2
commit d038f7c1a1

View file

@ -21,7 +21,11 @@ class CodeBlock extends HTMLElement{
} }
determineAndLoadContent(){ determineAndLoadContent(){
CodeBlock.getSource(this.src) const src = this.src;
if(!src){
return
}
CodeBlock.getSource(src)
.then( .then(
(data) => this.consumeData(data,CodeBlock.InsertMode.Replace), (data) => this.consumeData(data,CodeBlock.InsertMode.Replace),
(e) => this.consumeData({content:this.textContent},CodeBlock.InsertMode.Replace) (e) => this.consumeData({content:this.textContent},CodeBlock.InsertMode.Replace)
@ -313,7 +317,10 @@ class CodeBlock extends HTMLElement{
} }
get codeBox(){ get codeBox(){
return this.shadowRoot.querySelector("tbody"); if(!this._codeBox){
this._codeBox = this.shadowRoot.querySelector("tbody");
}
return this._codeBox;
} }
get value(){ get value(){
return this.codeBox.textContent return this.codeBox.textContent