Skip to content

Commit

Permalink
Merge pull request #1 from collecthor/fix-support-ssr
Browse files Browse the repository at this point in the history
fix: lazy template initialization
  • Loading branch information
SamMousa authored Oct 4, 2023
2 parents 80895e5 + bf67aca commit 576c6ca
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/js/template.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const template = document.createElement("div");
template.innerHTML = (
/**
@type null|HTMLDivElement
*/
let template = null;
const templateHTML = (

//'<div class=winbox>' +

Expand Down Expand Up @@ -31,6 +34,10 @@ template.innerHTML = (
);

export default function(tpl){
if (!template) {
template = document.createElement('div');
template.innerHTML = templateHTML;
}

return (tpl || template).cloneNode(true);
}

0 comments on commit 576c6ca

Please sign in to comment.