-
Notifications
You must be signed in to change notification settings - Fork 648
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
Tag params #1076
Tag params #1076
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1076 +/- ##
==========================================
+ Coverage 90.53% 90.56% +0.03%
==========================================
Files 305 307 +2
Lines 11636 11663 +27
==========================================
+ Hits 10535 10563 +28
+ Misses 1101 1100 -1
Continue to review full report at Codecov.
|
ok(typeof params === "string", '"params" should be a string'); | ||
ok(builder, '"builder" is required'); | ||
|
||
var parsed = builder.parseExpression("function(" + params + "){}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to parse this as an arrow function? Then the line numbers would already be right if we use them eventually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because parseExpression
converts to Marko AST and we don't have an arrow function node, it returns a generic Expression
node (which doesn't have the params attached). So function
it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I was concerned with some of the changes I made to parseJavaScript.js
. By using esprima
directly here I don't need to make those changes and can also use an arrow function.
Nice to see this work.. thanks. Is there a way to globally defined a feature flag? I don't currently rely on the old behaviour and I have many components that could make use of this feature but they don't currently have a tag def file for them |
Sorry if this is off topic - could this same syntax be used for event delegation ?
would cause the transcluded on-click handler to delegate to the handler that mouse-position provides as 'onClick' |
… make parseJavaScriptParams work by using esprima directly
Description
Implements #656/#851
Allow tag bodies to receive parameters
Parameters can be destructured, etc.
Feature Flag
We used to use this syntax to pass arguments to the custom tag and although this is now deprecated and replaced by spread attributes (#878), in order to avoid a breaking change this feature will live behind a feature flag until Marko 5.
marko.json
Checklist:
Disclaimer: Contributions via GitHub pull requests are gladly accepted from their original author. Along with any pull requests, please state that the contribution is your original work and that you license the work to the project under the project's open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project's open source license and warrant that you have the legal authority to do so.