瀏覽代碼

Update to check for the key itself

Kevin Batdorf 4 年之前
父節點
當前提交
36f2d56b6b
共有 3 個文件被更改,包括 6 次插入6 次删除
  1. 2 2
      dist/alpine-ie11.js
  2. 2 2
      dist/alpine.js
  3. 2 2
      src/directives/for.js

+ 2 - 2
dist/alpine-ie11.js

@@ -5997,9 +5997,9 @@
   }
 
   function lookAheadForMatchingKeyedElementAndMoveItIfFound(nextEl, currentKey) {
-    if (!nextEl) return; // If the next El is a sibling template tag, we're done.
+    if (!nextEl) return; // If the next El isn't keyed, we can ignore it.
 
-    if (nextEl.tagName.toLowerCase() === 'template') return; // If the the key's DO match, no need to look ahead.
+    if (nextEl.__x_for_key === undefined) return; // If the the key's DO match, no need to look ahead.
 
     if (nextEl.__x_for_key === currentKey) return nextEl; // If they don't, we'll look ahead for a match.
     // If we find it, we'll move it to the current position in the loop.

+ 2 - 2
dist/alpine.js

@@ -594,9 +594,9 @@
   }
 
   function lookAheadForMatchingKeyedElementAndMoveItIfFound(nextEl, currentKey) {
-    if (!nextEl) return; // If the next El is a sibling template tag, we're done.
+    if (!nextEl) return; // If the next El isn't keyed, we can ignore it.
 
-    if (nextEl.tagName.toLowerCase() === 'template') return; // If the the key's DO match, no need to look ahead.
+    if (nextEl.__x_for_key === undefined) return; // If the the key's DO match, no need to look ahead.
 
     if (nextEl.__x_for_key === currentKey) return nextEl; // If they don't, we'll look ahead for a match.
     // If we find it, we'll move it to the current position in the loop.

+ 2 - 2
src/directives/for.js

@@ -111,8 +111,8 @@ function addElementInLoopAfterCurrentEl(templateEl, currentEl) {
 function lookAheadForMatchingKeyedElementAndMoveItIfFound(nextEl, currentKey) {
     if (! nextEl) return
 
-    // If the next El is a sibling template tag, we're done.
-    if (nextEl.tagName.toLowerCase() === 'template') return
+    // If the next El isn't keyed, we can ignore it.
+    if (nextEl.__x_for_key === undefined) return
 
     // If the the key's DO match, no need to look ahead.
     if (nextEl.__x_for_key === currentKey) return nextEl