You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mercury-parser/src/utils/dom/within-comment.js

14 lines
397 B
JavaScript

import { getAttrs } from 'utils/dom';
export default function withinComment($node) {
const parents = $node.parents().toArray();
const commentParent = parents.find((parent) => {
const attrs = getAttrs(parent);
const { class: nodeClass, id } = attrs;
const classAndId = `${nodeClass} ${id}`;
return classAndId.includes('comment');
});
return commentParent !== undefined;
}