Parcourir la source

fix text parser ignoring last char

Evan You il y a 11 ans
Parent
commit
641d3a93ec
2 fichiers modifiés avec 9 ajouts et 1 suppressions
  1. 1 1
      src/parse/text.js
  2. 8 0
      test/unit/specs/parse/text_spec.js

+ 1 - 1
src/parse/text.js

@@ -95,7 +95,7 @@ exports.parse = function (text) {
     })
     lastIndex = index + match[0].length
   }
-  if (lastIndex < text.length - 1) {
+  if (lastIndex < text.length) {
     tokens.push({
       value: text.slice(lastIndex)
     })

+ 8 - 0
test/unit/specs/parse/text_spec.js

@@ -43,6 +43,14 @@ var testCases = [
       { value: ' and ' },
       { tag: true, value: 'hello', html: false, oneTime: false, partial: true }
     ]
+  },
+  {
+    text: '[{{abc}}]',
+    expected: [
+      { value: '[' },
+      { tag: true, value: 'abc', html: false, oneTime: false },
+      { value: ']' }
+    ]
   }
 ]