From ec50f0f86e6b97290feeaea197e2f4917a7f37e7 Mon Sep 17 00:00:00 2001 From: Ayo Date: Sat, 9 Dec 2023 22:35:58 +0100 Subject: [PATCH] refactor(templating): attributes handling & JSX - support unparented DOM nodes - simpler attributes handling - jsx-like syntax - use .mjs for utils --- examples/templating/index.js | 23 ++ package.json | 2 +- src/utils/create-element.js | 42 ---- src/utils/create-element.mjs | 29 +++ src/utils/{deserialize.js => deserialize.mjs} | 0 .../{get-camel-case.js => get-camel-case.mjs} | 0 .../{get-kebab-case.js => get-kebab-case.mjs} | 0 src/utils/index.js | 10 +- src/utils/{serialize.js => serialize.mjs} | 0 src/web-component-base.js | 200 ++++++++++++++++++ 10 files changed, 258 insertions(+), 48 deletions(-) delete mode 100644 src/utils/create-element.js create mode 100644 src/utils/create-element.mjs rename src/utils/{deserialize.js => deserialize.mjs} (100%) rename src/utils/{get-camel-case.js => get-camel-case.mjs} (100%) rename src/utils/{get-kebab-case.js => get-kebab-case.mjs} (100%) rename src/utils/{serialize.js => serialize.mjs} (100%) create mode 100644 src/web-component-base.js diff --git a/examples/templating/index.js b/examples/templating/index.js index c83704d..dd6019e 100644 --- a/examples/templating/index.js +++ b/examples/templating/index.js @@ -1,3 +1,4 @@ +// @ts-check import { WebComponent, html } from "../../src/index.js"; export class Counter extends WebComponent { @@ -5,6 +6,19 @@ export class Counter extends WebComponent { count: 123, }; get template() { + + const list = ['a', 'b', 'c', 'what'] + const links = [ + { + url: 'https://ayco.io', + text: 'Ayo Ayco' + }, + { + url: 'https://ayco.io/gh/McFly', + text: 'McFly' + } + ] + return html`