Skip to content

Does this do what I think it does? #237

Answered by ChristianMurphy
babakfp asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @babakfp! 👋

Does this do what I think it does?

It's unclear your full goal here, so it's hard to say.

I do index + 5 to tell it to ignore the next nodes, so it doesn't loop the custom nodes. Am I doing it correctly? Am I ignoring the correct number of indexes?

The best way to verify this is to create a test case. 🙂
One way to do this would be to add a warning attribute, and assert none of the visited nodes have that attribute

import { visit, SKIP } from 'unist-util-visit';

export default () => {
  return (tree) => {
    visit(tree, 'element', (node, index, parent) => {
      if (!parent || index === undefined) return;
      if (node.tagName === 'style' || node.tagName === 'script') 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by babakfp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants