From 9936fc1202f62828ca2477c3a3aa78b59f38a051 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sat, 24 Feb 2024 19:46:41 +0800 Subject: [PATCH] feat: clear used template --- src/lib/rsshub.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/rsshub.ts b/src/lib/rsshub.ts index 3bb3fbf4..f38d0109 100644 --- a/src/lib/rsshub.ts +++ b/src/lib/rsshub.ts @@ -7,7 +7,7 @@ import type { RSSData, Rule } from "./types" const parseHtml = (html) => { const template = document.createElement('template'); template.innerHTML = html; - return template.content; + return template; } function ruleHandler(rule: Rule, params, url, html, success, fail) { @@ -15,8 +15,9 @@ function ruleHandler(rule: Rule, params, url, html, success, fail) { let resultWithParams if (typeof rule.target === "function") { try { - const document = parseHtml(html) - resultWithParams = rule.target(params, url, document) + const template = parseHtml(html) + resultWithParams = rule.target(params, url, template.content) + template.remove() } catch (error) { resultWithParams = "" }