Skip to content
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

Correctly handle arrow function expression arguments when used with non-'on' properties #1672

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fresh-schools-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/mitosis': patch
---

Fix arrow function expressions in non-on properties
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

56 changes: 56 additions & 0 deletions packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,34 @@ Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} */
"
`;

exports[`Alpine.js > jsx > Javascript Test > functionProps 1`] = `
"<p
x-data=\\"myBasicComponent()\\"
x-bind:f=\\"() => x\\"
x-bind:f1=\\"x => x\\"
x-bind:f2=\\"x => {}\\"
x-bind:f3=\\"function () {
return x;
}\\"
x-bind:f4=\\"function (x) {
return x;
}\\"
x-bind:f5=\\"function (x) {
return;
}\\"
x-bind:f6=\\"function () {
return;
}\\"
x-bind:f7=\\"(a, b, c) => a + b + c\\"
></p>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Alpine.data(\\"myBasicComponent\\", () => ({}));
});
</script>
"
`;

exports[`Alpine.js > jsx > Javascript Test > getterState 1`] = `
"<div x-data=\\"button()\\">
<p><span x-html=\\"foo2\\"></span></p>
Expand Down Expand Up @@ -5143,6 +5171,34 @@ Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} */
"
`;

exports[`Alpine.js > jsx > Typescript Test > functionProps 1`] = `
"<p
x-data=\\"myBasicComponent()\\"
x-bind:f=\\"() => x\\"
x-bind:f1=\\"x => x\\"
x-bind:f2=\\"x => {}\\"
x-bind:f3=\\"function () {
return x;
}\\"
x-bind:f4=\\"function (x) {
return x;
}\\"
x-bind:f5=\\"function (x) {
return;
}\\"
x-bind:f6=\\"function () {
return;
}\\"
x-bind:f7=\\"(a, b, c) => a + b + c\\"
></p>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Alpine.data(\\"myBasicComponent\\", () => ({}));
});
</script>
"
`;

exports[`Alpine.js > jsx > Typescript Test > getterState 1`] = `
"<div x-data=\\"button()\\">
<p><span x-html=\\"foo2\\"></span></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4747,6 +4747,53 @@ export class FigmaButtonModule {}
"
`;

exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > functionProps 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"my-basic-component\\",
template: \`
<p
[attr.f]=\\"() => x\\"
[attr.f1]=\\"x => x\\"
[attr.f2]=\\"x => {}\\"
[attr.f3]=\\"function () {
return x;
}\\"
[attr.f4]=\\"function (x) {
return x;
}\\"
[attr.f5]=\\"function (x) {
return;
}\\"
[attr.f6]=\\"function () {
return;
}\\"
[attr.f7]=\\"(a, b, c) => a + b + c\\"
></p>
\`,
styles: [
\`
:host {
display: contents;
}
\`,
],
})
export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
exports: [MyBasicComponent],
})
export class MyBasicComponentModule {}
"
`;

exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > getterState 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down Expand Up @@ -12771,6 +12818,57 @@ export class FigmaButtonModule {}
"
`;

exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > functionProps 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

export interface MyBasicComponentProps {
id: string;
}

@Component({
selector: \\"my-basic-component\\",
template: \`
<p
[attr.f]=\\"() => x\\"
[attr.f1]=\\"x => x\\"
[attr.f2]=\\"x => {}\\"
[attr.f3]=\\"function () {
return x;
}\\"
[attr.f4]=\\"function (x) {
return x;
}\\"
[attr.f5]=\\"function (x) {
return;
}\\"
[attr.f6]=\\"function () {
return;
}\\"
[attr.f7]=\\"(a, b, c) => a + b + c\\"
></p>
\`,
styles: [
\`
:host {
display: contents;
}
\`,
],
})
export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
exports: [MyBasicComponent],
})
export class MyBasicComponentModule {}
"
`;

exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > getterState 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4819,6 +4819,54 @@ export class FigmaButtonModule {}
"
`;

exports[`Angular with Import Mapper Tests > jsx > Javascript Test > functionProps 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"my-basic-component\\",
template: \`
<p
[attr.f]=\\"() => x\\"
[attr.f1]=\\"x => x\\"
[attr.f2]=\\"x => {}\\"
[attr.f3]=\\"function () {
return x;
}\\"
[attr.f4]=\\"function (x) {
return x;
}\\"
[attr.f5]=\\"function (x) {
return;
}\\"
[attr.f6]=\\"function () {
return;
}\\"
[attr.f7]=\\"(a, b, c) => a + b + c\\"
></p>
\`,
styles: [
\`
:host {
display: contents;
}
\`,
],
})
export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
exports: [MyBasicComponent],
bootstrap: [SomeOtherComponent],
})
export class MyBasicComponentModule {}
"
`;

exports[`Angular with Import Mapper Tests > jsx > Javascript Test > getterState 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down Expand Up @@ -12973,6 +13021,58 @@ export class FigmaButtonModule {}
"
`;

exports[`Angular with Import Mapper Tests > jsx > Typescript Test > functionProps 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

export interface MyBasicComponentProps {
id: string;
}

@Component({
selector: \\"my-basic-component\\",
template: \`
<p
[attr.f]=\\"() => x\\"
[attr.f1]=\\"x => x\\"
[attr.f2]=\\"x => {}\\"
[attr.f3]=\\"function () {
return x;
}\\"
[attr.f4]=\\"function (x) {
return x;
}\\"
[attr.f5]=\\"function (x) {
return;
}\\"
[attr.f6]=\\"function () {
return;
}\\"
[attr.f7]=\\"(a, b, c) => a + b + c\\"
></p>
\`,
styles: [
\`
:host {
display: contents;
}
\`,
],
})
export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
exports: [MyBasicComponent],
bootstrap: [SomeOtherComponent],
})
export class MyBasicComponentModule {}
"
`;

exports[`Angular with Import Mapper Tests > jsx > Typescript Test > getterState 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down
Loading