mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-29 07:27:22 +08:00
style: replace .contents().remove() with .empty()
This commit is contained in:
@@ -606,10 +606,6 @@
|
||||
"selector": "CallExpression[callee.property.name='clone'][arguments.length=0]:not([callee.object.name=/^(request|response|req|res)$/])",
|
||||
"message": "Usage of .clone() in cheerio is not allowed."
|
||||
},
|
||||
{
|
||||
"selector": "CallExpression[callee.property.name='empty'][arguments.length=0]",
|
||||
"message": "Usage of .empty() in cheerio is not allowed."
|
||||
},
|
||||
{
|
||||
"selector": "CallExpression[callee.property.name='toArray'] MemberExpression[object.callee.property.name='map']",
|
||||
"message": "Use .toArray() before .map()."
|
||||
|
||||
@@ -35,7 +35,7 @@ const parseArticle = async (link: string, excerpt?: string): Promise<Pick<DataIt
|
||||
|
||||
content.find('.share-container, .addthis_tool').remove();
|
||||
// The site's YouTube embeds leak their attributes into the iframe as text.
|
||||
content.find('iframe').contents().remove();
|
||||
content.find('iframe').empty();
|
||||
content.find('.wp-caption-text').each((_, el) => {
|
||||
$(el).replaceWith($('<figcaption>').append($(el).contents()));
|
||||
});
|
||||
|
||||
@@ -95,7 +95,7 @@ async function handler(ctx) {
|
||||
const video = content(element);
|
||||
const poster = copyNodes(video.find('.sdc-site-video__poster img').first());
|
||||
const caption = copyNodes(video.find('.sdc-site-video__caption').first());
|
||||
video.contents().remove();
|
||||
video.empty();
|
||||
video.append(poster, caption);
|
||||
});
|
||||
|
||||
|
||||
@@ -103,6 +103,6 @@ function copyContent<T extends AnyNode>(selection: Cheerio<T>, $: CheerioAPI): C
|
||||
return $(nodes);
|
||||
}
|
||||
function clearContent<T extends AnyNode>(selection: Cheerio<T>): Cheerio<T> {
|
||||
selection.contents().remove();
|
||||
selection.empty();
|
||||
return selection;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user