From 663e797954721016625142c6a38d2915c0a6a698 Mon Sep 17 00:00:00 2001 From: memdmp Date: Mon, 26 Jan 2026 06:20:31 +0100 Subject: feat: an RSS --- src/lib/vendor/rss/xml.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/lib/vendor/rss/xml.ts') diff --git a/src/lib/vendor/rss/xml.ts b/src/lib/vendor/rss/xml.ts index 30618c0..8a0d2c4 100644 --- a/src/lib/vendor/rss/xml.ts +++ b/src/lib/vendor/rss/xml.ts @@ -52,11 +52,11 @@ export abstract class XMLTagWithAttributes extends BaseXMLTag { } } export abstract class XMLTagWithChildrenAndAttributes extends XMLTagWithAttributes { - public children: BaseXMLTag[] = []; + public children: XMLTag[] = []; protected get contentString() { return this.children.map(v => v.toString()).join('\n'); } - public child(...children: BaseXMLTag[]) { + public child(...children: XMLTag[]) { this.children.push(...children); return this; } @@ -82,6 +82,9 @@ export class XMLDeclaration extends XMLTagWithChildrenAndAttributes { export class XMLElement extends XMLTagWithChildrenAndAttributes { public readonly tagType = XMLTagType.Element as const; public constructor(public tagName: string) { super() } + protected findElementChild(query: (element: XMLElement) => boolean) { + return this.children.find(el => el.tagType === XMLTagType.Element && query(el)) as XMLElement + } public toString(): string { return `<${this.tagName}${this.attributeString}${this.children.length ? `> ${indent(this.contentString, 2)} @@ -138,4 +141,4 @@ export class XMLCData extends BaseXMLTag { return `/gu, ']]]]>')}]]>`; } } -export type XMLTag = XMLDocumentRoot | XMLDeclaration | XMLElement | XMLComment; +export type XMLTag = XMLDocumentRoot | XMLDeclaration | XMLElement | XMLText | XMLComment | XMLCData; -- cgit v1.2.3