Skip to content

Commit

Permalink
Fix/class classname consolidation (#1584)
Browse files Browse the repository at this point in the history
* f

* f

* f
  • Loading branch information
samijaber authored Oct 7, 2024
1 parent 4e277a9 commit dad8e2f
Show file tree
Hide file tree
Showing 28 changed files with 628 additions and 184 deletions.
5 changes: 5 additions & 0 deletions .changeset/soft-moles-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/mitosis': patch
---

Fix: do not consolidate class and className for Mitosis components
18 changes: 14 additions & 4 deletions packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1500,8 +1500,13 @@ exports[`Alpine.js > jsx > Javascript Test > class + ClassName + css 1`] = `
padding: 10px;
}
</style>
<div class=\\"test2 test div\\" x-data=\\"myBasicComponent()\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div x-data=\\"myBasicComponent()\\">
<MyComp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</MyComp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Expand Down Expand Up @@ -4288,8 +4293,13 @@ exports[`Alpine.js > jsx > Typescript Test > class + ClassName + css 1`] = `
padding: 10px;
}
</style>
<div class=\\"test2 test div\\" x-data=\\"myBasicComponent()\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div x-data=\\"myBasicComponent()\\">
<MyComp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</MyComp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3339,11 +3339,18 @@ import { CommonModule } from \\"@angular/common\\";

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

import MyComp from \\"./my-component.lite\\";

@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div>
<my-comp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</my-comp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
\`,
styles: [
Expand All @@ -3361,7 +3368,7 @@ export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
imports: [CommonModule, MyCompModule],
exports: [MyBasicComponent],
})
export class MyBasicComponentModule {}
Expand Down Expand Up @@ -10522,11 +10529,18 @@ import { CommonModule } from \\"@angular/common\\";

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

import MyComp from \\"./my-component.lite\\";

@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div>
<my-comp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</my-comp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
\`,
styles: [
Expand All @@ -10544,7 +10558,7 @@ export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
imports: [CommonModule, MyCompModule],
exports: [MyBasicComponent],
})
export class MyBasicComponentModule {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3384,11 +3384,18 @@ import { CommonModule } from \\"@angular/common\\";

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

import MyCompModule from \\"./my-component.lite/angular\\";

@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div>
<my-comp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</my-comp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
\`,
styles: [
Expand All @@ -3406,7 +3413,7 @@ export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
imports: [CommonModule, MyCompModule],
exports: [MyBasicComponent],
bootstrap: [SomeOtherComponent],
})
Expand Down Expand Up @@ -10682,11 +10689,18 @@ import { CommonModule } from \\"@angular/common\\";

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

import MyCompModule from \\"./my-component.lite/angular\\";

@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div>
<my-comp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</my-comp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
\`,
styles: [
Expand All @@ -10704,7 +10718,7 @@ export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
imports: [CommonModule, MyCompModule],
exports: [MyBasicComponent],
bootstrap: [SomeOtherComponent],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3447,8 +3447,13 @@ import { Component } from \\"@angular/core\\";
@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div>
<my-comp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</my-comp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
\`,
styles: [
Expand All @@ -3466,7 +3471,7 @@ export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
imports: [CommonModule, MyCompModule],
exports: [MyBasicComponent],
})
export class MyBasicComponentModule {}
Expand Down Expand Up @@ -10875,8 +10880,13 @@ import { Component } from \\"@angular/core\\";
@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div>
<my-comp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</my-comp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
\`,
styles: [
Expand All @@ -10894,7 +10904,7 @@ export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
imports: [CommonModule, MyCompModule],
exports: [MyBasicComponent],
})
export class MyBasicComponentModule {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3063,8 +3063,13 @@ import { Component } from \\"@angular/core\\";
@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div>
<my-comp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</my-comp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
\`,
styles: [
Expand All @@ -3079,7 +3084,7 @@ export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
imports: [CommonModule, MyCompModule],
exports: [MyBasicComponent],
})
export class MyBasicComponentModule {}
Expand Down Expand Up @@ -9515,8 +9520,13 @@ import { Component } from \\"@angular/core\\";
@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div>
<my-comp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</my-comp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
\`,
styles: [
Expand All @@ -9531,7 +9541,7 @@ export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
imports: [CommonModule, MyCompModule],
exports: [MyBasicComponent],
})
export class MyBasicComponentModule {}
Expand Down
48 changes: 36 additions & 12 deletions packages/core/src/__tests__/__snapshots__/angular.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6356,8 +6356,13 @@ import { Component } from \\"@angular/core\\";
@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div>
<my-comp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</my-comp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
\`,
styles: [
Expand All @@ -6375,7 +6380,7 @@ export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
imports: [CommonModule, MyCompModule],
exports: [MyBasicComponent],
})
export class MyBasicComponentModule {}
Expand All @@ -6386,11 +6391,18 @@ exports[`Angular > jsx > Javascript Test > class + ClassName + css 2`] = `
"import { Component } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import MyComp from \\"./my-component.js\\";

@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div>
<my-comp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</my-comp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
\`,
styles: [
Expand All @@ -6404,7 +6416,7 @@ import { CommonModule } from \\"@angular/common\\";
\`,
],
standalone: true,
imports: [CommonModule],
imports: [CommonModule, MyComp],
})
export default class MyBasicComponent {}
"
Expand Down Expand Up @@ -19887,8 +19899,13 @@ import { Component } from \\"@angular/core\\";
@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div>
<my-comp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</my-comp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
\`,
styles: [
Expand All @@ -19906,7 +19923,7 @@ export default class MyBasicComponent {}

@NgModule({
declarations: [MyBasicComponent],
imports: [CommonModule],
imports: [CommonModule, MyCompModule],
exports: [MyBasicComponent],
})
export class MyBasicComponentModule {}
Expand All @@ -19917,11 +19934,18 @@ exports[`Angular > jsx > Typescript Test > class + ClassName + css 2`] = `
"import { Component } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import MyComp from \\"./my-component.js\\";

@Component({
selector: \\"my-basic-component\\",
template: \`
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
<div>
<my-comp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</my-comp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
\`,
styles: [
Expand All @@ -19935,7 +19959,7 @@ import { CommonModule } from \\"@angular/common\\";
\`,
],
standalone: true,
imports: [CommonModule],
imports: [CommonModule, MyComp],
})
export default class MyBasicComponent {}
"
Expand Down
18 changes: 14 additions & 4 deletions packages/core/src/__tests__/__snapshots__/html.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3610,8 +3610,13 @@ exports[`Html > jsx > Javascript Test > basicOnUpdateReturn 1`] = `
`;

exports[`Html > jsx > Javascript Test > class + ClassName + css 1`] = `
"<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
"<div>
<MyComp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</MyComp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
<style>
.div {
Expand Down Expand Up @@ -10550,8 +10555,13 @@ exports[`Html > jsx > Typescript Test > basicOnUpdateReturn 1`] = `
`;

exports[`Html > jsx > Typescript Test > class + ClassName + css 1`] = `
"<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
"<div>
<MyComp class=\\"test\\" className=\\"test2\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</MyComp>
<div class=\\"test2 test div\\">
Hello! I can run in React, Vue, Solid, or Liquid!
</div>
</div>
<style>
.div {
Expand Down
Loading

0 comments on commit dad8e2f

Please sign in to comment.