-
Notifications
You must be signed in to change notification settings - Fork 32
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
[BUGFIX] Contextual component variable transformation #230
base: master
Are you sure you want to change the base?
Changes from 1 commit
4d03b5d
53b4b27
1e1b610
944e85a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ const HTML_ATTRIBUTES = ['class', 'placeholder', 'required']; | |
const BUILT_IN_COMPONENTS = ['link-to', 'input', 'textarea']; | ||
|
||
let inAttr = false; | ||
let havingBlockParams = false; | ||
let currentBlockParams = []; | ||
|
||
function isAttribute(key) { | ||
return HTML_ATTRIBUTES.includes(key) || isDataAttribute(key); | ||
|
@@ -435,16 +437,23 @@ function transformToAngleBracket(fileInfo, config, invokableData) { | |
node.loc.source !== '(synthetic)' && | ||
!shouldIgnoreMustacheStatement(tagName, config, invokableData); | ||
const isNestedComponent = isNestedComponentTagName(tagName); | ||
const isNotBlockParamValue = | ||
!havingBlockParams && !currentBlockParams.includes(node.path.original); | ||
|
||
if ( | ||
isValidMustache && | ||
(node.hash.pairs.length > 0 || node.params.length > 0 || isNestedComponent) | ||
(node.hash.pairs.length > 0 || node.params.length > 0 || isNestedComponent) && | ||
isNotBlockParamValue | ||
) { | ||
return transformNode(node, fileInfo, config); | ||
} | ||
}, | ||
BlockStatement(node) { | ||
let tagName = `${node.path.original}`; | ||
havingBlockParams = node.program.blockParams.length > 0; | ||
if (havingBlockParams) { | ||
currentBlockParams = node.program.blockParams; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesn't work for nested block params There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Turbo87 Can you give me an example? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the corresponding template-lint rule has something like this implemented, or you can have a look at the implicit-this codemod |
||
} | ||
if ( | ||
!shouldIgnoreMustacheStatement(node.path.original, config, invokableData) || | ||
isWallStreet(tagName) | ||
|
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.
this seems unrelated to the PR?!
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.
Yep, sorry my bad, it was meant to be in a separate PR, will remove it.