Skip to content

Commit eceeacf

Browse files
authored
Merge branch 'main' into feat-mitosis-native-cond-loops
2 parents e3f4037 + e68ac40 commit eceeacf

File tree

8 files changed

+88
-63
lines changed

8 files changed

+88
-63
lines changed

e2e/e2e-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"@builder.io/mitosis": "workspace:*",
1616
"@builder.io/mitosis-cli": "workspace:*",
17-
"@playwright/test": "^1.34.0",
17+
"@playwright/test": "^1.48.0",
1818
"watch": "^1.0.2"
1919
},
2020
"devDependencies": {

packages/cli/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @builder.io/mitosis-cli
22

3+
## 0.5.4
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [d13e693]
8+
- @builder.io/[email protected]
9+
310
## 0.5.3
411

512
### Patch Changes

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@builder.io/mitosis-cli",
3-
"version": "0.5.3",
3+
"version": "0.5.4",
44
"description": "mitosis CLI",
55
"types": "build/types/types.d.ts",
66
"bin": {

packages/core/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## 0.5.4
4+
5+
### Patch Changes
6+
7+
- d13e693: [LIT] Bug: Passing wrong object for transforming ref(Element ref) result in breakage
8+
39
## 0.5.3
410

511
### Patch Changes

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"name": "Builder.io",
2323
"url": "https://www.builder.io"
2424
},
25-
"version": "0.5.3",
25+
"version": "0.5.4",
2626
"homepage": "https://github.com/BuilderIO/mitosis",
2727
"main": "./dist/src/index.js",
2828
"exports": {

packages/core/src/__tests__/__snapshots__/lit.test.ts.snap

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default class MyBasicRefComponent extends LitElement {
2222

2323
onBlur = function onBlur() {
2424
// Maintain focus
25-
inputRef.focus();
25+
this.inputRef.focus();
2626
};
2727
lowerCaseName = function lowerCaseName() {
2828
return this.name.toLowerCase();
@@ -428,7 +428,7 @@ export default class MyBasicRefComponent extends LitElement {
428428

429429
onBlur = function onBlur() {
430430
// Maintain focus
431-
inputRef.focus();
431+
this.inputRef.focus();
432432
};
433433
lowerCaseName = function lowerCaseName() {
434434
return this.name.toLowerCase();
@@ -476,8 +476,8 @@ export default class MyBasicRefAssignmentComponent extends LitElement {
476476

477477
handlerClick = function handlerClick(event) {
478478
event.preventDefault();
479-
console.log(\\"current value\\", holdValueRef);
480-
holdValueRef = holdValueRef + \\"JS\\";
479+
console.log(\\"current value\\", this.holdValueRef);
480+
this.holdValueRef = this.holdValueRef + \\"JS\\";
481481
};
482482

483483
render() {
@@ -517,7 +517,7 @@ export default class MyPreviousComponent extends LitElement {
517517
@state() count = 0;
518518

519519
updated() {
520-
prevCount = this.count;
520+
this.prevCount = this.count;
521521
}
522522

523523
render() {
@@ -527,7 +527,7 @@ export default class MyPreviousComponent extends LitElement {
527527
Now:
528528
\${this.count}
529529
, before:
530-
\${prevCount}</h1>
530+
\${this.prevCount}</h1>
531531
<button @click=\${(event) =>
532532
(this.count += 1)} >Increment</button></div>
533533
\`;
@@ -756,9 +756,9 @@ export default class CustomCode extends LitElement {
756756

757757
findAndRunScripts() {
758758
// TODO: Move this function to standalone one in '@builder.io/utils'
759-
if (elem && typeof window !== \\"undefined\\") {
759+
if (this.elem && typeof window !== \\"undefined\\") {
760760
/** @type {HTMLScriptElement[]} */
761-
const scripts = elem.getElementsByTagName(\\"script\\");
761+
const scripts = this.elem.getElementsByTagName(\\"script\\");
762762

763763
for (let i = 0; i < scripts.length; i++) {
764764
const script = scripts[i];
@@ -831,9 +831,9 @@ export default class CustomCode extends LitElement {
831831

832832
findAndRunScripts() {
833833
// TODO: Move this function to standalone one in '@builder.io/utils'
834-
if (elem && typeof window !== \\"undefined\\") {
834+
if (this.elem && typeof window !== \\"undefined\\") {
835835
/** @type {HTMLScriptElement[]} */
836-
const scripts = elem.getElementsByTagName(\\"script\\");
836+
const scripts = this.elem.getElementsByTagName(\\"script\\");
837837

838838
for (let i = 0; i < scripts.length; i++) {
839839
const script = scripts[i];
@@ -1041,8 +1041,8 @@ export default class FormComponent extends LitElement {
10411041
},
10421042
});
10431043

1044-
if (formRef) {
1045-
formRef.dispatchEvent(presubmitEvent);
1044+
if (this.formRef) {
1045+
this.formRef.dispatchEvent(presubmitEvent);
10461046

10471047
if (presubmitEvent.defaultPrevented) {
10481048
return;
@@ -1100,28 +1100,28 @@ export default class FormComponent extends LitElement {
11001100
},
11011101
});
11021102

1103-
if (formRef) {
1104-
formRef.dispatchEvent(submitSuccessEvent);
1103+
if (this.formRef) {
1104+
this.formRef.dispatchEvent(submitSuccessEvent);
11051105

11061106
if (submitSuccessEvent.defaultPrevented) {
11071107
return;
11081108
}
11091109
/* TODO: option to turn this on/off? */
11101110

11111111
if (this.resetFormOnSubmit !== false) {
1112-
formRef.reset();
1112+
this.formRef.reset();
11131113
}
11141114
}
11151115
/* TODO: client side route event first that can be preventDefaulted */
11161116

11171117
if (this.successUrl) {
1118-
if (formRef) {
1118+
if (this.formRef) {
11191119
const event = new CustomEvent(\\"route\\", {
11201120
detail: {
11211121
url: this.successUrl,
11221122
},
11231123
});
1124-
formRef.dispatchEvent(event);
1124+
this.formRef.dispatchEvent(event);
11251125

11261126
if (!event.defaultPrevented) {
11271127
location.href = this.successUrl;
@@ -1139,8 +1139,8 @@ export default class FormComponent extends LitElement {
11391139
},
11401140
});
11411141

1142-
if (formRef) {
1143-
formRef.dispatchEvent(submitErrorEvent);
1142+
if (this.formRef) {
1143+
this.formRef.dispatchEvent(submitErrorEvent);
11441144

11451145
if (submitErrorEvent.defaultPrevented) {
11461146
return;
@@ -1241,8 +1241,8 @@ export default class Image extends LitElement {
12411241
if (this.useLazyLoading()) {
12421242
// throttled scroll capture listener
12431243
const listener = () => {
1244-
if (pictureRef) {
1245-
const rect = pictureRef.getBoundingClientRect();
1244+
if (this.pictureRef) {
1245+
const rect = this.pictureRef.getBoundingClientRect();
12461246
const buffer = window.innerHeight / 2;
12471247

12481248
if (rect.top < window.innerHeight + buffer) {
@@ -2779,7 +2779,7 @@ export default class Embed extends LitElement {
27792779
}
27802780

27812781
connectedCallback() {
2782-
elem.dispatchEvent(new CustomEvent(\\"initEditingBldr\\"));
2782+
this.elem.dispatchEvent(new CustomEvent(\\"initEditingBldr\\"));
27832783
}
27842784

27852785
render() {
@@ -4267,7 +4267,7 @@ export default class MyBasicRefComponent extends LitElement {
42674267

42684268
onBlur = function onBlur() {
42694269
// Maintain focus
4270-
inputRef.focus();
4270+
this.inputRef.focus();
42714271
};
42724272
lowerCaseName = function lowerCaseName() {
42734273
return this.name.toLowerCase();
@@ -4691,7 +4691,7 @@ export default class MyBasicRefComponent extends LitElement {
46914691

46924692
onBlur = function onBlur() {
46934693
// Maintain focus
4694-
inputRef.focus();
4694+
this.inputRef.focus();
46954695
};
46964696
lowerCaseName = function lowerCaseName() {
46974697
return this.name.toLowerCase();
@@ -4743,8 +4743,8 @@ export default class MyBasicRefAssignmentComponent extends LitElement {
47434743

47444744
handlerClick = function handlerClick(event: Event) {
47454745
event.preventDefault();
4746-
console.log(\\"current value\\", holdValueRef);
4747-
holdValueRef = holdValueRef + \\"JS\\";
4746+
console.log(\\"current value\\", this.holdValueRef);
4747+
this.holdValueRef = this.holdValueRef + \\"JS\\";
47484748
};
47494749

47504750
render() {
@@ -4788,7 +4788,7 @@ export default class MyPreviousComponent extends LitElement {
47884788
@state() count = 0;
47894789

47904790
updated() {
4791-
prevCount = this.count;
4791+
this.prevCount = this.count;
47924792
}
47934793

47944794
render() {
@@ -4798,7 +4798,7 @@ export default class MyPreviousComponent extends LitElement {
47984798
Now:
47994799
\${this.count}
48004800
, before:
4801-
\${prevCount}</h1>
4801+
\${this.prevCount}</h1>
48024802
<button @click=\${(event) =>
48034803
(this.count += 1)} >Increment</button></div>
48044804
\`;
@@ -5067,9 +5067,9 @@ export default class CustomCode extends LitElement {
50675067

50685068
findAndRunScripts() {
50695069
// TODO: Move this function to standalone one in '@builder.io/utils'
5070-
if (elem && typeof window !== \\"undefined\\") {
5070+
if (this.elem && typeof window !== \\"undefined\\") {
50715071
/** @type {HTMLScriptElement[]} */
5072-
const scripts = elem.getElementsByTagName(\\"script\\");
5072+
const scripts = this.elem.getElementsByTagName(\\"script\\");
50735073

50745074
for (let i = 0; i < scripts.length; i++) {
50755075
const script = scripts[i];
@@ -5147,9 +5147,9 @@ export default class CustomCode extends LitElement {
51475147

51485148
findAndRunScripts() {
51495149
// TODO: Move this function to standalone one in '@builder.io/utils'
5150-
if (elem && typeof window !== \\"undefined\\") {
5150+
if (this.elem && typeof window !== \\"undefined\\") {
51515151
/** @type {HTMLScriptElement[]} */
5152-
const scripts = elem.getElementsByTagName(\\"script\\");
5152+
const scripts = this.elem.getElementsByTagName(\\"script\\");
51535153

51545154
for (let i = 0; i < scripts.length; i++) {
51555155
const script = scripts[i];
@@ -5388,8 +5388,8 @@ export default class FormComponent extends LitElement {
53885388
},
53895389
});
53905390

5391-
if (formRef) {
5392-
formRef.dispatchEvent(presubmitEvent);
5391+
if (this.formRef) {
5392+
this.formRef.dispatchEvent(presubmitEvent);
53935393

53945394
if (presubmitEvent.defaultPrevented) {
53955395
return;
@@ -5447,28 +5447,28 @@ export default class FormComponent extends LitElement {
54475447
},
54485448
});
54495449

5450-
if (formRef) {
5451-
formRef.dispatchEvent(submitSuccessEvent);
5450+
if (this.formRef) {
5451+
this.formRef.dispatchEvent(submitSuccessEvent);
54525452

54535453
if (submitSuccessEvent.defaultPrevented) {
54545454
return;
54555455
}
54565456
/* TODO: option to turn this on/off? */
54575457

54585458
if (this.resetFormOnSubmit !== false) {
5459-
formRef.reset();
5459+
this.formRef.reset();
54605460
}
54615461
}
54625462
/* TODO: client side route event first that can be preventDefaulted */
54635463

54645464
if (this.successUrl) {
5465-
if (formRef) {
5465+
if (this.formRef) {
54665466
const event = new CustomEvent(\\"route\\", {
54675467
detail: {
54685468
url: this.successUrl,
54695469
},
54705470
});
5471-
formRef.dispatchEvent(event);
5471+
this.formRef.dispatchEvent(event);
54725472

54735473
if (!event.defaultPrevented) {
54745474
location.href = this.successUrl;
@@ -5486,8 +5486,8 @@ export default class FormComponent extends LitElement {
54865486
},
54875487
});
54885488

5489-
if (formRef) {
5490-
formRef.dispatchEvent(submitErrorEvent);
5489+
if (this.formRef) {
5490+
this.formRef.dispatchEvent(submitErrorEvent);
54915491

54925492
if (submitErrorEvent.defaultPrevented) {
54935493
return;
@@ -5610,8 +5610,8 @@ export default class Image extends LitElement {
56105610
if (this.useLazyLoading()) {
56115611
// throttled scroll capture listener
56125612
const listener = () => {
5613-
if (pictureRef) {
5614-
const rect = pictureRef.getBoundingClientRect();
5613+
if (this.pictureRef) {
5614+
const rect = this.pictureRef.getBoundingClientRect();
56155615
const buffer = window.innerHeight / 2;
56165616

56175617
if (rect.top < window.innerHeight + buffer) {
@@ -7335,7 +7335,7 @@ export default class Embed extends LitElement {
73357335
}
73367336

73377337
connectedCallback() {
7338-
elem.dispatchEvent(new CustomEvent(\\"initEditingBldr\\"));
7338+
this.elem.dispatchEvent(new CustomEvent(\\"initEditingBldr\\"));
73397339
}
73407340

73417341
render() {

packages/core/src/generators/lit/generate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export const componentToLit: TranspilerGenerator<ToLitOptions> =
138138
let css = collectCss(json);
139139

140140
const domRefs = getRefs(json);
141-
mapRefs(component, (refName) => `this.${camelCase(refName)}`);
141+
mapRefs(json, (refName) => `this.${camelCase(refName)}`);
142142

143143
if (options.plugins) {
144144
json = runPostJsonPlugins({ json, plugins: options.plugins });

0 commit comments

Comments
 (0)