Skip to content

Commit

Permalink
core template: drop the part done by pagecut, use template.content if…
Browse files Browse the repository at this point in the history
… possible
  • Loading branch information
kapouer committed Feb 19, 2020
1 parent ed593e6 commit fac0cbd
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/site/ui/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@ class HTMLElementTemplate extends HTMLCustomElement {
};
}
static prepareTemplate(node) {
if (node.isContentEditable) return node;
var doc = node.ownerDocument;
var tmpl = node;
var helper;
if (node.matches('script[type="text/html"]')) {
helper = doc.createElement('div');
helper.innerHTML = node.textContent;
tmpl = doc.createElement('template');
if (!tmpl.content) tmpl.content = doc.createDocumentFragment();
tmpl.content.appendChild(node.dom(helper.textContent));
if (!tmpl.content) {
tmpl.content = doc.createDocumentFragment();
tmpl.content.appendChild(node.dom(helper.textContent));
} else {
tmpl.innerHTML = helper.textContent;
}
node.replaceWith(tmpl);
node.textContent = helper.textContent = '';
}
if (tmpl.isContentEditable) {
if (tmpl.content && tmpl.children.length == 0) {
tmpl.textContent = '';
tmpl.appendChild(tmpl.content);
}
} else if (document.visibilityState == "prerender") {
var dest = tmpl.dom(`<script type="text/html"></script>`);
if (!helper) helper = doc.createElement('div');
Expand Down

0 comments on commit fac0cbd

Please sign in to comment.