From 01dcd2fcc4d8bde2458258c94b317e114c1f9756 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 30 Dec 2023 15:14:36 -0400 Subject: html: make isTag and isTemplate proper validators --- src/util/html.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/util/html.js b/src/util/html.js index 0c29ecd1..32350236 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -6,6 +6,10 @@ import {colors} from '#cli'; import {empty, typeAppearance} from '#sugar'; import * as commonValidators from '#validators'; +const { + validateInstanceOf, +} = commonValidators; + // COMPREHENSIVE! // https://html.spec.whatwg.org/multipage/syntax.html#void-elements export const selfClosingTags = [ @@ -72,14 +76,6 @@ export function isBlank(value) { return value.length === 0; } -export function isTag(value) { - return value instanceof Tag; -} - -export function isTemplate(value) { - return value instanceof Template; -} - export function isHTML(value) { if (typeof value === 'string') { return true; @@ -1238,3 +1234,9 @@ export class Stationery { : `Stationery ${colors.dim(`(no annotation)`)}`)); } } + +export const isTag = + validateInstanceOf(Tag); + +export const isTemplate = + validateInstanceOf(Template); -- cgit 1.3.0-6-gf8a5