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

fix: issues for vue composition api #1558

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
5 changes: 5 additions & 0 deletions .changeset/perfect-cups-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/mitosis': patch
---

fix: issues with vue composition api
nmerget marked this conversation as resolved.
Show resolved Hide resolved
124 changes: 122 additions & 2 deletions packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ exports[`Alpine.js > jsx > Javascript Test > BasicRef 1`] = `
name: \\"PatrickJS\\",
onBlur: function onBlur() {
// Maintain focus
this.$refs.inputRef.focus();
this.$refs.inputRef?.focus();
},
lowerCaseName: function lowerCaseName() {
return this.name.toLowerCase();
Expand Down Expand Up @@ -1070,6 +1070,23 @@ exports[`Alpine.js > jsx > Javascript Test > InputParent 1`] = `
"
`;

exports[`Alpine.js > jsx > Javascript Test > NestedStore 1`] = `
"<div x-data=\\"nestedStore()\\" x-bind:id=\\"_id\\">
Test

<p x-bind:id=\\"_messageId\\">Message</p>
</div>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Alpine.data(\\"nestedStore\\", () => ({
_id: \\"abc\\",
_messageId: this._id + \\"-message\\",
}));
});
</script>
"
`;

exports[`Alpine.js > jsx > Javascript Test > RawText 1`] = `
"<span
x-data=\\"rawText()\\"
Expand Down Expand Up @@ -1332,6 +1349,33 @@ exports[`Alpine.js > jsx > Javascript Test > Textarea 1`] = `
"
`;

exports[`Alpine.js > jsx > Javascript Test > UseValueAndFnFromStore 1`] = `
"<div x-data=\\"useValueAndFnFromStore()\\" x-effect=\\"onUpdate\\">Test</div>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Alpine.data(\\"useValueAndFnFromStore\\", () => ({
_id: \\"abc\\",
_active: false,

_do(id) {
this._active = !!id;

if (props.onChange) {
props.onChange(this._active);
}
},

onUpdate() {
if (this._do) {
this._do(this._id);
}
},
}));
});
</script>
"
`;

exports[`Alpine.js > jsx > Javascript Test > Video 1`] = `
"<video
preload=\\"none\\"
Expand Down Expand Up @@ -2417,6 +2461,22 @@ exports[`Alpine.js > jsx > Javascript Test > self-referencing component with chi
"
`;

exports[`Alpine.js > jsx > Javascript Test > setState 1`] = `
"<div x-data=\\"setState()\\"><button x-on:click=\\"someFn\\">Click me</button></div>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Alpine.data(\\"setState\\", () => ({
n: [\\"123\\"],

someFn() {
this.n[0] = \\"123\\";
},
}));
});
</script>
"
`;

exports[`Alpine.js > jsx > Javascript Test > showExpressions 1`] = `
"<div x-data=\\"showWithOtherValues()\\">
<template x-if=\\"conditionA\\">Content0</template>
Expand Down Expand Up @@ -3062,7 +3122,7 @@ exports[`Alpine.js > jsx > Typescript Test > BasicRef 1`] = `
name: \\"PatrickJS\\",
onBlur: function onBlur() {
// Maintain focus
this.$refs.inputRef.focus();
this.$refs.inputRef?.focus();
},
lowerCaseName: function lowerCaseName() {
return this.name.toLowerCase();
Expand Down Expand Up @@ -3814,6 +3874,23 @@ exports[`Alpine.js > jsx > Typescript Test > InputParent 1`] = `
"
`;

exports[`Alpine.js > jsx > Typescript Test > NestedStore 1`] = `
"<div x-data=\\"nestedStore()\\" x-bind:id=\\"_id\\">
Test

<p x-bind:id=\\"_messageId\\">Message</p>
</div>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Alpine.data(\\"nestedStore\\", () => ({
_id: \\"abc\\",
_messageId: this._id + \\"-message\\",
}));
});
</script>
"
`;

exports[`Alpine.js > jsx > Typescript Test > RawText 1`] = `
"<span
x-data=\\"rawText()\\"
Expand Down Expand Up @@ -4076,6 +4153,33 @@ exports[`Alpine.js > jsx > Typescript Test > Textarea 1`] = `
"
`;

exports[`Alpine.js > jsx > Typescript Test > UseValueAndFnFromStore 1`] = `
"<div x-data=\\"useValueAndFnFromStore()\\" x-effect=\\"onUpdate\\">Test</div>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Alpine.data(\\"useValueAndFnFromStore\\", () => ({
_id: \\"abc\\",
_active: false,

_do(id?: string) {
this._active = !!id;

if (props.onChange) {
props.onChange(this._active);
}
},

onUpdate() {
if (this._do) {
this._do(this._id);
}
},
}));
});
</script>
"
`;

exports[`Alpine.js > jsx > Typescript Test > Video 1`] = `
"<video
preload=\\"none\\"
Expand Down Expand Up @@ -5164,6 +5268,22 @@ exports[`Alpine.js > jsx > Typescript Test > self-referencing component with chi
"
`;

exports[`Alpine.js > jsx > Typescript Test > setState 1`] = `
"<div x-data=\\"setState()\\"><button x-on:click=\\"someFn\\">Click me</button></div>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Alpine.data(\\"setState\\", () => ({
n: [\\"123\\"],

someFn() {
this.n[0] = \\"123\\";
},
}));
});
</script>
"
`;

exports[`Alpine.js > jsx > Typescript Test > showExpressions 1`] = `
"<div x-data=\\"showWithOtherValues()\\">
<template x-if=\\"conditionA\\">Content0</template>
Expand Down
Loading