From 77b68bf272e7425ae49223226c761bb8857b5d2e05dec3326fa18f7a0556429d Mon Sep 17 00:00:00 2001 From: evilchili Date: Sat, 17 Oct 2026 18:09:19 -0700 Subject: [PATCH] add tag.getByname() --- dist/tags/base.d.ts | 1 + dist/tags/base.js | 5 +++++ src/ts/tags/base.ts | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/dist/tags/base.d.ts b/dist/tags/base.d.ts index e398ad7..83507cf 100644 --- a/dist/tags/base.d.ts +++ b/dist/tags/base.d.ts @@ -32,6 +32,7 @@ export declare class TagCollection implements TagCollectionType { tags: TagType[]; map: Map; constructor(tags: TagType[]); + getByName(name: string): TagType; getByElementName(element: string): TagType | undefined; } export {}; diff --git a/dist/tags/base.js b/dist/tags/base.js index 4db3609..62b6f44 100644 --- a/dist/tags/base.js +++ b/dist/tags/base.js @@ -143,6 +143,11 @@ class TagCollection { } } } + getByName(name) { + return this.tags.filter(t => { + t.constructor.name == name; + })[0] || undefined; + } getByElementName(element) { const el = element.toUpperCase(); return this.tags.filter(t => { diff --git a/src/ts/tags/base.ts b/src/ts/tags/base.ts index 85a7bb8..be9c6d1 100644 --- a/src/ts/tags/base.ts +++ b/src/ts/tags/base.ts @@ -157,6 +157,12 @@ export class TagCollection implements TagCollectionType { } } + getByName(name: string) { + return this.tags.filter(t => { + t.constructor.name == name + })[0] || undefined; + } + getByElementName(element: string): TagType | undefined { const el = element.toUpperCase(); return this.tags.filter(t => {