Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(transformElement): properly transform replaced nodes #2927

Merged
merged 2 commits into from
Mar 29, 2021

Conversation

Calvin-LL
Copy link
Contributor

@Calvin-LL Calvin-LL commented Jan 2, 2021

Problem:

I was trying to make a transform that uses replaceNode to replace the currentNode with a new element node.

Since I pass in my transform in TransformOptions["nodeTransforms"], it comes after all the transforms in BaseTransformPreset which includes transformElement.

So

Even though I can create my own codegenNode in my own exit function, I don't think having postTransformElement transform a node that is no longer in the tree is the desired behavior.

Solution:

Instead of using a reference to the node transformElement is first called with, use context.currentNode

@posva
Copy link
Member

posva commented Jan 4, 2021

can you add a test?

@Calvin-LL
Copy link
Contributor Author

can you add a test?

Oops forgot to add a test, just added one

@HcySunYang HcySunYang added the 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. label Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants