Pārlūkot izejas kodu

Fix teleport morphing

Caleb Porzio 1 gadu atpakaļ
vecāks
revīzija
51af64232d
1 mainītis faili ar 5 papildinājumiem un 4 dzēšanām
  1. 5 4
      packages/morph/src/morph.js

+ 5 - 4
packages/morph/src/morph.js

@@ -120,6 +120,11 @@ export function morph(from, toHtml, options) {
     }
     }
 
 
     function patchChildren(from, to) {
     function patchChildren(from, to) {
+        // If we hit a <template x-teleport="body">,
+        // let's use the teleported nodes for this patch...
+        if (from._x_teleport) from = from._x_teleport
+        if (to._x_teleport) to = to._x_teleport
+
         let fromKeys = keyToMap(from.children)
         let fromKeys = keyToMap(from.children)
         let fromKeyHoldovers = {}
         let fromKeyHoldovers = {}
 
 
@@ -444,10 +449,6 @@ function getFirstNode(parent) {
 }
 }
 
 
 function getNextSibling(parent, reference) {
 function getNextSibling(parent, reference) {
-    if (reference._x_teleport) {
-        return reference._x_teleport
-    }
-
     let next
     let next
 
 
     if (parent instanceof Block) {
     if (parent instanceof Block) {