Teleported x-data using async alpine broken on Alpine ^v3.14.4 #4467
-
Hi i'm using async alpine and after Alpine.js ^v3.14.4 it broke the teleported here's the minimal bug reproduction: index.html (try change to alpine version ^v3.14.4 to v3.14.3 then see the console) <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/async-alpine.script.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js" defer></script> -->
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js" defer></script> -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js" defer></script>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="flex items-center justify-center w-full h-dvh">
<div x-data="{ open: false }">
<button type="button" x-on:click="open = !open">Toggle</button>
<template x-teleport="body">
<div
class="h-dvh fixed inset-0 z-50 w-full bg-slate-950/50 flex items-center justify-center"
x-show="open"
x-cloak
x-on:click="open =! open"
>
<div x-load x-load-src="async-alpine.js" x-ignore x-data="asyncAlpineData" class="bg-pink-500 text-white"></div>
<div
x-data="{
init(){
console.log('inline alpine data')
}
}"
></div>
</div>
</template>
</div>
</body>
</html> async-alpine.js export default function asyncAlpineData() {
return {
init() {
this.$root.innerHTML = "foo";
console.log("hello");
},
};
} |
Beta Was this translation helpful? Give feedback.
Answered by
joshhanley
Dec 6, 2024
Replies: 1 comment 21 replies
-
fixed in #4450 |
Beta Was this translation helpful? Give feedback.
21 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had a look this with Caleb on our call this morning and we think the teleport
clone._x_ignore = true
was something for Livewire. But we're not 100% on that. Caleb said to just try removing it and see if both test suites pass.So I've submitted an Alpine PR #4469 with it removed and a Livewire PR livewire/livewire#9072 with the Alpine fix and both test suites are passing.