Skip to content

Commit

Permalink
Merge pull request #162 from collecthor/fix-support-ssr
Browse files Browse the repository at this point in the history
fix: lazy template initialization
  • Loading branch information
ts-thomas authored Dec 21, 2023
2 parents 80895e5 + bf67aca commit bbb453a
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 bbb453a

Please sign in to comment.