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
(feat) enable actions to enhance typings on applied element #1553
Changes from 1 commit
05995aa
e155d65
3e84fd7
74bb725
f243d4c
48c1453
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 |
---|---|---|
@@ -1,32 +1,9 @@ | ||
import MagicString from 'magic-string'; | ||
import { BaseDirective } from '../../interfaces'; | ||
import { | ||
getDirectiveNameStartEndIdx, | ||
rangeWithTrailingPropertyAccess, | ||
TransformationArray | ||
} from '../utils/node-utils'; | ||
import { Element } from './Element'; | ||
|
||
/** | ||
* use:xxx={params} ---> __sveltets_2_ensureAction(xxx(svelte.mapElementTag('ParentNodeName'),(params))); | ||
*/ | ||
export function handleActionDirective( | ||
str: MagicString, | ||
attr: BaseDirective, | ||
element: Element | ||
): void { | ||
const transformations: TransformationArray = [ | ||
'__sveltets_2_ensureAction(', | ||
getDirectiveNameStartEndIdx(str, attr), | ||
`(${element.typingsNamespace}.mapElementTag('${element.tagName}')` | ||
]; | ||
if (attr.expression) { | ||
transformations.push( | ||
',(', | ||
rangeWithTrailingPropertyAccess(str.original, attr.expression), | ||
')' | ||
); | ||
} | ||
transformations.push('));'); | ||
element.appendToStartEnd(transformations); | ||
export function handleActionDirective(attr: BaseDirective, element: Element): void { | ||
element.addAction(attr); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
not sure if this comment is still valid?