Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update license info #21

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
18 changes: 10 additions & 8 deletions src/WebComponent.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @license MIT <https://opensource.org/licenses/MIT>
* @author Ayo Ayco <https://ayo.ayco.io>
*/

import {
createElement,
getKebabCase,
Expand All @@ -8,9 +13,7 @@ import {

/**
* A minimal base class to reduce the complexity of creating reactive custom elements
* @license MIT <https://opensource.org/licenses/MIT>
* @author Ayo Ayco <https://ayo.ayco.io>
* @see https://www.npmjs.com/package/web-component-base#readme
* @see https://WebComponent.io
*/
export class WebComponent extends HTMLElement {
/**
Expand All @@ -21,6 +24,8 @@ export class WebComponent extends HTMLElement {

/**
* Blueprint for the Proxy props
* @typedef {{[name: string]: any}} PropStringMap
* @type {PropStringMap}
*/
static props;

Expand All @@ -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}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
);
}
}
Expand All @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions src/html.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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 <https://www.apache.org/licenses/LICENSE-2.0>
* @author Jason Miller <[email protected]>
*/
export const html = htm.bind(h);
2 changes: 2 additions & 0 deletions src/vendors/htm/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down