aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/vendor/rss/xml.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/vendor/rss/xml.ts')
-rw-r--r--src/lib/vendor/rss/xml.ts9
1 files changed, 6 insertions, 3 deletions
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 `<![CDATA[${this.content.replace(/\]\]>/gu, ']]]]><![CDATA[>')}]]>`;
}
}
-export type XMLTag = XMLDocumentRoot | XMLDeclaration | XMLElement | XMLComment;
+export type XMLTag = XMLDocumentRoot | XMLDeclaration | XMLElement | XMLText | XMLComment | XMLCData;