Browse code

Initial htmx npm packages installation

Benjamin Roth authored on25/05/2023 09:52:13
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+htmx.defineExtension('alpine-morph', {
2
+    isInlineSwap: function (swapStyle) {
3
+        return swapStyle === 'morph';
4
+    },
5
+    handleSwap: function (swapStyle, target, fragment) {
6
+        if (swapStyle === 'morph') {
7
+            if (fragment.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
8
+                Alpine.morph(target, fragment.firstElementChild);
9
+                return [target];
10
+            } else {
11
+                Alpine.morph(target, fragment.outerHTML);
12
+                return [target];
13
+            }
14
+        }
15
+    }
16
+});
0 17
\ No newline at end of file