Jelajahi Sumber

Simplified. Omitting the case of negative value.

Peter Minne 4 tahun lalu
induk
melakukan
c592e449ac
2 mengubah file dengan 2 tambahan dan 6 penghapusan
  1. 2 2
      src/directives/for.js
  2. 0 4
      test/for.spec.js

+ 2 - 2
src/directives/for.js

@@ -95,8 +95,8 @@ function evaluateItemsAndReturnEmptyIfXIfIsPresentAndFalseOnElement(component, e
     let items = component.evaluateReturnExpression(el, iteratorNames.items, extraVars)
 
     // This adds support for the `i in n` syntax.
-    if (isNumeric(items)) {
-        items = items > 0 ? Array.from(Array(items).keys(), i => i = 1) : []
+    if (isNumeric(items) && items >= 0) {
+        items = Array.from(Array(items).keys(), i => i + 1)
     }
 
     return items

+ 0 - 4
test/for.spec.js

@@ -572,8 +572,4 @@ test('x-for over range using i in x syntax with i <= 0', async () => {
     document.querySelector('button').click()
 
     await wait(() => { expect(document.querySelectorAll('span').length).toEqual(0) })
-
-    document.querySelector('button').click()
-
-    await wait(() => { expect(document.querySelectorAll('span').length).toEqual(0) })
 })