Skip to content

Commit

Permalink
Fixes bug when normal element - SVG defs - used as template. Changes …
Browse files Browse the repository at this point in the history
…debuyg.css to module.css.
  • Loading branch information
stephband committed Dec 18, 2023
1 parent c88b9ad commit c41c169
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ comments:
modules:
rm -rf ./build
deno run --allow-read --allow-env --allow-net --allow-write --allow-run ../fn/deno/make-modules.js build \
debug.css \
module.css \
module.js \
data/clock.js \
literal-element/module.js \
Expand Down
2 changes: 1 addition & 1 deletion documentation/module.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
@import './elements/code.css';
@import './elements/details-toggle.css';

@import '../debug.css';
@import '../module.css';
6 changes: 3 additions & 3 deletions literal-html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ <h3 id="an-example">An example</h3>

</section>


<nav>
<details-toggle class="nav-details-toggle">
<button slot="summary" class="nav-thumb thumb">
Expand Down Expand Up @@ -408,7 +408,7 @@ <h3 id="an-example">An example</h3>
</details-toggle>
</nav>


<hr class="x1 4x @2-x2 x-stretch" style="margin-top: 4.2em;" />

<div class="x1 4x @2-x2 x-stretch y-start">
Expand All @@ -425,7 +425,7 @@ <h3 id="an-example">An example</h3>
</p>
</div>


<footer class="x1 4x @1-6x @2-7x @3-9x 4x-grid @1-6x-grid @2-7x-grid @3-9x-grid grid grid footer">
<div class="x1 4x @1-2x @2-x2 x-stretch y-start">
<h3>Elements</h3>
Expand Down
File renamed without changes.
18 changes: 13 additions & 5 deletions modules/renderer-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,18 @@ function compileContent(content, message) {
return renderers;
}

function compileTemplate(template, id) {
const content = template.content
|| create('fragment', template.childNodes, template) ;

const renderers = compileContent(content, '#' + id);

return { id, content, renderers };
}

function createRenderer(Renderer) {
//console.log(Renderer.path, Renderer.name, Renderer.path ? getElement(Renderer.path, this.content) : this.element, this.content);

// `this` is the TemplateRenderer
const renderer = Renderer.path ?
// Where `.path` exists find the element at the end of the path
Expand All @@ -124,11 +135,8 @@ function createRenderer(Renderer) {
export default function TemplateRenderer(template, element = template.parentElement, parameters = {}) {
const id = identify(template) ;

const content = template.content
|| create('fragment', template.childNodes, template) ;

const renderers = cache[id]
|| (cache[id] = compileContent(content, '#' + id)) ;
const { content, renderers } = cache[id]
|| (cache[id] = compileTemplate(template, id));

this.element = element;
this.parameters = parameters;
Expand Down

0 comments on commit c41c169

Please sign in to comment.