-
Notifications
You must be signed in to change notification settings - Fork 644
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
[MARKO-3] - <assign> and <var> tag migration #1158
Conversation
@timlauter this looks good 😄! Would you mind updating the two failing snapshot tests to get the CI passing? |
Codecov Report
@@ Coverage Diff @@
## master #1158 +/- ##
==========================================
- Coverage 90.52% 90.48% -0.04%
==========================================
Files 311 311
Lines 11803 11808 +5
==========================================
Hits 10685 10685
- Misses 1118 1123 +5
Continue to review full report at Codecov.
|
Added
<var>
and<assign>
migration transforms so users can still use the deprecated syntax, but allowing the reference to not be a breaking change in Marko V4.Description
Both the
<assign>
and<var>
tag have their attributes looped through to get transformed from a type ofHtmlAttribute
to aScriptlet
.In the assign tag, one of two cases happen. Either the attribute name gets assigned a value, or the attribute name's value remains
undefined
. During this assignment, the newScriptlet
that is created is inserted as a sibling before the original elNode. After, the original elNode is detached.The var tag has similar functionality to the assign tag. However, there are two differences. While looping through the attributes of the elNode, the attribute names are actually being defined as a variable and assigned rather than only being referenced. Again, during this assignment, the new
Scriptlet
that is created is inserted as a sibling before the original elNode. Before the detachment of the original elNode, it's children are looped over and inserted as a sibling before the original elNode to not lose the children that are referencing the declared variable.Allows users to reference deprecated code without it breaking on compilation because the way the user wrote to code is transformed into how the code should be written.
Checklist: