Implement NodeTransform that transforms child props based on parent props? #12916
Unanswered
ozzyfromspace
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context: The deeper goal is to perform an AST transformation on a child node's props using information from a parent node's props. I'm genuinely stuck.
Lets assume I have the following:
My goal in this example is to perform a node transformation on the
<option />
props by identifying which option should be selected based ondefaultValue
andvalue
. After the AST transform, we should get a template with aselected
attribute, like so:My approach has been to define a
NodeTransformation
function that grabs theSimpleExpressionNode
and compares it to some other expression. However, I get:[Vue warn]: Property "$setup" was accessed during render but is not defined on instance.
I believe this is happening because the context that contains the variables in the SFC's setup tags are unavailable to
<option />
, but I could be wrong. Could someone more knowledgeable please help me understand how I can actually implement an AST that assigns the correctselected
attribute to the<option />
tag?Please let me know if I can supply anything else that makes it easier for you to provide guidance. Many thanks in advance!
Disclaimer: I am aware that this is a solved problem through v-model. This question exists because I have other considerations that disqualify v-model.
Beta Was this translation helpful? Give feedback.
All reactions