From 776abf8d697716902692f357c6f179c1e681369f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 8 Apr 2023 16:54:39 -0300 Subject: html: drastically simplify template/slot system --- test/snapshot/generateAdditionalFilesList.js | 4 ++-- test/unit/util/html.js | 17 +++++------------ 2 files changed, 7 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/snapshot/generateAdditionalFilesList.js b/test/snapshot/generateAdditionalFilesList.js index ce876d8d..0c27ad19 100644 --- a/test/snapshot/generateAdditionalFilesList.js +++ b/test/snapshot/generateAdditionalFilesList.js @@ -42,7 +42,7 @@ testContentFunctions(t, 'generateAdditionalFilesList (snapshot)', async (t, eval ], ], postprocess: template => template - .slot('additionalFileLinks', { + .slot('fileLinks', { 'sburbwp_1280x1024.jpg': 'link to 1280x1024', 'sburbwp_1440x900.jpg': 'link to 1440x900', 'sburbwp_1920x1080.jpg': null, @@ -50,7 +50,7 @@ testContentFunctions(t, 'generateAdditionalFilesList (snapshot)', async (t, eval 'Homestuck_Vol4_alt2.jpg': null, 'Homestuck_Vol4_alt3.jpg': 'link to alt3', }) - .slot('additionalFileSizes', { + .slot('fileSizes', { 'sburbwp_1280x1024.jpg': 2500, 'sburbwp_1440x900.jpg': null, 'sburbwp_1920x1080.jpg': null, diff --git a/test/unit/util/html.js b/test/unit/util/html.js index 9925d2da..045dad91 100644 --- a/test/unit/util/html.js +++ b/test/unit/util/html.js @@ -1,10 +1,10 @@ import t from 'tap'; import * as html from '../../../src/util/html.js'; -const {Tag, Attributes, Template, Slot} = html; +const {Tag, Attributes, Template} = html; t.test(`html.tag`, t => { - t.plan(16); + t.plan(14); const tag1 = html.tag('div', @@ -26,10 +26,8 @@ t.test(`html.tag`, t => { t.equal(tag2.content[1], 'children'); const genericTag = html.tag('div'); - let genericSlot; - const genericTemplate = html.template(slot => { - genericSlot = slot('title'); - return html.blank(); + const genericTemplate = html.template({ + content: () => html.blank(), }); // 9-10: tag treated as content, not attributes @@ -42,12 +40,7 @@ t.test(`html.tag`, t => { t.equal(tag4.content.length, 1); t.equal(tag4.content[0], genericTemplate); - // 13-14: slot treated as content, not attributes - const tag5 = html.tag('div', genericSlot); - t.equal(tag5.content.length, 1); - t.equal(tag5.content[0], genericSlot); - - // 15-16: deep flattening support + // 13-14: deep flattening support const tag6 = html.tag('div', [ true && -- cgit 1.3.0-6-gf8a5