diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-12-30 15:14:17 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-12-30 15:49:11 -0400 |
commit | 9bde2140700ab243ace40b959784f2338283ef9c (patch) | |
tree | fcb71fd94c82bd7b51e3f40c0bbe11bb60ed6cc4 | |
parent | 5c4e3b1341c35d676b8f1d89c70dd03266986950 (diff) |
html: use direct instanceof checks instead of isTag, isTemplate
-rw-r--r-- | src/util/html.js | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/util/html.js b/src/util/html.js index df7fa8c4..0c29ecd1 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -57,11 +57,11 @@ export const blockwrap = Symbol(); // html.blank()) and false for Tags and Templates (regardless of contents or // other properties). Don't depend on this to match any other values. export function isBlank(value) { - if (isTag(value)) { + if (value instanceof Tag) { return false; } - if (isTemplate(value)) { + if (value instanceof Template) { return false; } @@ -89,7 +89,7 @@ export function isHTML(value) { return true; } - if (isBlank(value) || isTag(value) || isTemplate(value)) { + if (isBlank(value) || value instanceof Tag || value instanceof Template) { return true; } @@ -111,7 +111,7 @@ export function isAttributes(value) { return false; } - if (isTag(value) || isTemplate(value)) { + if (value instanceof Tag || value instanceof Template) { return false; } @@ -132,19 +132,11 @@ export const validators = { }, isTag(value) { - if (!isTag(value)) { - throw new TypeError(`Expected HTML tag`); - } - - return true; + return isTag(value); }, isTemplate(value) { - if (!isTemplate(value)) { - throw new TypeError(`Expected HTML template`); - } - - return true; + return isTemplate(value); }, isHTML(value) { @@ -1077,7 +1069,7 @@ export class Template { case 'string': { // Tags and templates are valid in string arguments - they'll be // stringified when exposed to the description's .content() function. - if (isTag(value) || isTemplate(value)) + if (value instanceof Tag || value instanceof Template) return true; if (typeof value !== 'string') @@ -1115,7 +1107,7 @@ export class Template { } if (description.type === 'string') { - if (isTag(providedValue) || isTemplate(providedValue)) { + if (providedValue instanceof Tag || providedValue instanceof Template) { return providedValue.toString(); } } |