|
1 | | -(function(){ |
2 | | - function createMorphConfig(swapStyle) { |
3 | | - if (swapStyle === 'morph' || swapStyle === 'morph:outerHTML') { |
4 | | - return {morphStyle: 'outerHTML'} |
5 | | - } else if (swapStyle === 'morph:innerHTML') { |
6 | | - return {morphStyle: 'innerHTML'} |
7 | | - } else if (swapStyle.startsWith("morph:")) { |
8 | | - return Function("return (" + swapStyle.slice(6) + ")")(); |
9 | | - } |
| 1 | +(function () { |
| 2 | + function createMorphConfig(swapStyle) { |
| 3 | + if (swapStyle === "morph" || swapStyle === "morph:outerHTML") { |
| 4 | + return { morphStyle: "outerHTML" }; |
| 5 | + } else if (swapStyle === "morph:innerHTML") { |
| 6 | + return { morphStyle: "innerHTML" }; |
| 7 | + } else if (swapStyle.startsWith("morph:")) { |
| 8 | + return Function("return (" + swapStyle.slice(6) + ")")(); |
10 | 9 | } |
| 10 | + } |
11 | 11 |
|
12 | | - htmx.defineExtension('morph', { |
13 | | - isInlineSwap: function(swapStyle) { |
14 | | - let config = createMorphConfig(swapStyle); |
15 | | - return config?.morphStyle === "outerHTML" || config?.morphStyle == null; |
16 | | - }, |
17 | | - handleSwap: function (swapStyle, target, fragment) { |
18 | | - let config = createMorphConfig(swapStyle); |
19 | | - if (config) { |
20 | | - return Idiomorph.morph(target, fragment.children, config); |
21 | | - } |
22 | | - } |
23 | | - }); |
24 | | -})() |
| 12 | + htmx.defineExtension("morph", { |
| 13 | + isInlineSwap: function (swapStyle) { |
| 14 | + let config = createMorphConfig(swapStyle); |
| 15 | + return config?.morphStyle === "outerHTML" || config?.morphStyle == null; |
| 16 | + }, |
| 17 | + handleSwap: function (swapStyle, target, fragment) { |
| 18 | + let config = createMorphConfig(swapStyle); |
| 19 | + if (config) { |
| 20 | + return Idiomorph.morph(target, fragment.children, config); |
| 21 | + } |
| 22 | + }, |
| 23 | + }); |
| 24 | +})(); |
0 commit comments