From 5720901d256d0890bfdd0b1ed1b35a1aed84d722 Mon Sep 17 00:00:00 2001 From: Ayo Ayco Date: Tue, 12 Dec 2023 22:06:12 +0100 Subject: [PATCH] chore: update license info (#21) --- package.json | 4 ++-- src/WebComponent.js | 18 ++++++++++-------- src/html.js | 9 +++++---- src/vendors/htm/LICENSE.txt | 2 ++ 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index d98a743..6641a78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "web-component-base", - "version": "2.0.0", + "version": "2.0.1", "description": "A zero-dependency & tiny JS base class for creating reactive custom elements easily", "type": "module", "exports": { @@ -32,7 +32,7 @@ "site": "npm start -w site", "build": "npm run clean && tsc && npm run copy:meta && npm run copy:source", "clean": "rm -rf dist", - "copy:meta": "node prepare.js && cp README.md ./dist && cp LICENSE ./dist", + "copy:meta": "node prepare.js && cp README.md ./dist && cp LICENSE ./dist && cp -r ./src/vendors ./dist", "copy:source": "esbuild --minify --bundle ./src/*.js ./src/utils/* --outdir=\"./dist\" --format=\"esm\"", "pub": "npm run clean && npm run build && cd ./dist && npm publish", "pub:beta": "npm run clean && npm run build && cd ./dist && npm publish --tag beta", diff --git a/src/WebComponent.js b/src/WebComponent.js index 2739415..d78e18b 100644 --- a/src/WebComponent.js +++ b/src/WebComponent.js @@ -1,3 +1,8 @@ +/** + * @license MIT + * @author Ayo Ayco + */ + import { createElement, getKebabCase, @@ -8,9 +13,7 @@ import { /** * A minimal base class to reduce the complexity of creating reactive custom elements - * @license MIT - * @author Ayo Ayco - * @see https://www.npmjs.com/package/web-component-base#readme + * @see https://WebComponent.io */ export class WebComponent extends HTMLElement { /** @@ -21,6 +24,8 @@ export class WebComponent extends HTMLElement { /** * Blueprint for the Proxy props + * @typedef {{[name: string]: any}} PropStringMap + * @type {PropStringMap} */ static props; @@ -35,7 +40,6 @@ export class WebComponent extends HTMLElement { /** * Read-only property containing camelCase counterparts of observed attributes. - * @typedef {{[name: string]: any}} PropStringMap * @see https://www.npmjs.com/package/web-component-base#prop-access * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset * @type {PropStringMap} @@ -141,7 +145,7 @@ export class WebComponent extends HTMLElement { throw TypeError( `Cannot assign ${typeof value} to ${ typeMap[prop] - } property (setting '${prop}' of ${meta.constructor.name})`, + } property (setting '${prop}' of ${meta.constructor.name})` ); } else if (oldValue !== value) { obj[prop] = value; @@ -176,7 +180,7 @@ export class WebComponent extends HTMLElement { if (!this.#props) { this.#props = new Proxy( initialProps, - this.#handler((key, value) => this.setAttribute(key, value), this), + this.#handler((key, value) => this.setAttribute(key, value), this) ); } } @@ -185,13 +189,11 @@ export class WebComponent extends HTMLElement { render() { if (typeof this.template === "string") { this.innerHTML = this.template; - return; } else if (typeof this.template === "object") { const tree = this.template; // TODO: smart diffing if (JSON.stringify(this.#prevDOM) !== JSON.stringify(tree)) { - // render const el = createElement(tree); if (el) { if (Array.isArray(el)) this.replaceChildren(...el); diff --git a/src/html.js b/src/html.js index 176ed54..dfd0290 100644 --- a/src/html.js +++ b/src/html.js @@ -1,7 +1,3 @@ -/** - * htm -- https://github.com/developit/htm - * For license information please see ./vendors/htm/LICENSE.txt - */ const htm = (new Map(), function (n) { @@ -77,4 +73,9 @@ function h(type, props, ...children) { return { type, props, children }; } +/** + * For htm license information please see ./vendors/htm/LICENSE.txt + * @license Apache + * @author Jason Miller + */ export const html = htm.bind(h); diff --git a/src/vendors/htm/LICENSE.txt b/src/vendors/htm/LICENSE.txt index f107611..8f3ff16 100644 --- a/src/vendors/htm/LICENSE.txt +++ b/src/vendors/htm/LICENSE.txt @@ -1,3 +1,5 @@ +This license applies to parts of the `html` function originating from https://github.com/developit/htm project: + Apache License Version 2.0, January 2004