diff --git a/package.json b/package.json index e40d15b..727573a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wkit", - "version": "1.10.14", + "version": "1.11.0", "type": "module", "description": "A library for building fast, lightweight web components.", "main": "dist/index.js", diff --git a/src/constants.js b/src/constants.js index 49e7b79..afb01be 100644 --- a/src/constants.js +++ b/src/constants.js @@ -101,7 +101,7 @@ function getType(v) { return { type, default: v, attribute } default: - return { type: String, default: v + '' } + return { type: null, default: '' } } } @@ -131,6 +131,10 @@ export function parsePropsDeclaration(options) { options = { type: Array } break + case String: + options = { type: String } + break + default: options = getType(options) break @@ -174,6 +178,9 @@ export function fixedValue(value, options) { } } + case null: + return value + default: return value === null || value === void 0 ? null : value + '' } diff --git a/src/index.js b/src/index.js index 690f48d..c110ec4 100644 --- a/src/index.js +++ b/src/index.js @@ -296,7 +296,7 @@ export class Component extends HTMLElement { let options = this.#getPropOptions(name) || {} let attrName = options.attrName - if (options.attribute === false) { + if (options.attribute === false || options.type === null) { this.removeAttribute(attrName) return } @@ -340,7 +340,7 @@ export class Component extends HTMLElement { if (options) { value = fixedValue(value, options) - if (options.attribute === false) { + if (options.attribute === false || options.type === null) { if (value === null) { return }