From 00e7f705a2aa3642d097a6e2c8201e693464769e Mon Sep 17 00:00:00 2001 From: Stephen Date: Sun, 14 Jul 2024 06:00:22 +0200 Subject: [PATCH] Synchronous ding dings --- modules/compile/compile-attribute.js | 3 +-- modules/compile/compile-node.js | 12 ++++++------ modules/scope/include.js | 14 ++++---------- modules/template.js | 2 +- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/modules/compile/compile-attribute.js b/modules/compile/compile-attribute.js index 9998bf3..13681ad 100644 --- a/modules/compile/compile-attribute.js +++ b/modules/compile/compile-attribute.js @@ -58,8 +58,7 @@ export default function compileAttribute(array, element, attribute, path, messag message = truncate(64, '<' + element.tagName.toLowerCase() + ' ' + name + '="' + source - + '">') - + ' (' + message + ')' ; + + '">') ; } // We need the Renderer here just to get .parameterNames. This is a bit diff --git a/modules/compile/compile-node.js b/modules/compile/compile-node.js index 4d3de23..58475b3 100644 --- a/modules/compile/compile-node.js +++ b/modules/compile/compile-node.js @@ -138,12 +138,12 @@ const compileNode = overload((targets, node) => toType(node), { const source = decode(string); if (window.DEBUG) { - const parent = node.parentElement || { tagName: 'template' }; - message = truncate(64, '<' - + parent.tagName.toLowerCase() + '>' - + source.trim() - + '') - + ' (' + message + ')' ; + const parent = node.parentElement; + const tag = parent && parent.tagName.toLowerCase(); + message = truncate(64, tag ? + '<' + tag + '>' + source.trim() + '' : + source.trim() + ); } //targets.push(new TextRenderer(path, indexOf(node), source, message, options, node)); diff --git a/modules/scope/include.js b/modules/scope/include.js index 65b01de..58110b0 100644 --- a/modules/scope/include.js +++ b/modules/scope/include.js @@ -19,17 +19,11 @@ ${ data.array.map(include('#list-item')) } **/ import Data from '../../../fn/modules/signal-data.js'; -import Template from '../template.js'; import getById from '../dom/get-by-id.js'; +import Template from '../template.js'; import requestTemplate from '../request-template.js'; import requestData from '../request-data.js'; -function push(template, data, element, parameters, options) { - const renderer = new Template(template, element, parameters, data, options); - //renderer.push(data); - return renderer; -} - function pipe(template, data, element, parameters, options) { const renderer = new Template(template, element, parameters, options); data.each((data) => renderer.push(data)); @@ -51,7 +45,7 @@ export default function include(src, data, element, parameters, options) { // Support JSON or module URLs if (dataRequest) { - return dataRequest.then((data) => push(template, data, element, parameters, options)); + return dataRequest.then((data) => new Template(template, element, parameters, data, options)); } // Support a stream of data @@ -60,7 +54,7 @@ export default function include(src, data, element, parameters, options) { } // Support object or ... ? - return push(template, object || {}, element, parameters, options); + return new Template(template, element, parameters, object, options); } // Template is external to document @@ -78,7 +72,7 @@ export default function include(src, data, element, parameters, options) { return Promise .all([templateRequest, dataRequest]) - .then(([template, data]) => push(template, data, element, parameters)); + .then(([template, data]) => new Template(template, element, parameters, data, options)); } diff --git a/modules/template.js b/modules/template.js index 990c6b4..4e6f669 100644 --- a/modules/template.js +++ b/modules/template.js @@ -132,7 +132,7 @@ export default class Template { this.parameters = parameters; this.first = content.childNodes[0]; this.last = content.childNodes[content.childNodes.length - 1]; - this.#data = Signal.of(data); + this.#data = Signal.of(Data.of(data)); this.contents = compiled.targets // We must find targets in cloned content .map(this.#toRendererParams, this)