if (element.previousSibling !== null) {
const lowerName = element.previousSibling.nodeName.toLowerCase();
const tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'img'];
if (!tags.includes(lowerName) {
// ...
}
}
const tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'img'];
if (element.previousSibling !== null && !tags.includes(element.previousSibling.nodeName.toLowerCase())) {
// ...
}