Przeglądaj źródła

revert v-for alias two-way binding warning (fix #1778)

Evan You 10 lat temu
rodzic
commit
50a79e48a4
1 zmienionych plików z 4 dodań i 13 usunięć
  1. 4 13
      src/watcher.js

+ 4 - 13
src/watcher.js

@@ -145,26 +145,17 @@ Watcher.prototype.set = function (value) {
   }
   // two-way sync for v-for alias
   var forContext = scope.$forContext
-  if (process.env.NODE_ENV !== 'production') {
-    if (
-      forContext &&
-      forContext.filters &&
-      (new RegExp(forContext.alias + '\\b')).test(this.expression)
-    ) {
-      _.warn(
+  if (forContext && forContext.alias === this.expression) {
+    if (forContext.filters) {
+      process.env.NODE_ENV !== 'production' && _.warn(
         'It seems you are using two-way binding on ' +
         'a v-for alias (' + this.expression + '), and the ' +
         'v-for has filters. This will not work properly. ' +
         'Either remove the filters or use an array of ' +
         'objects and bind to object properties instead.'
       )
+      return
     }
-  }
-  if (
-    forContext &&
-    forContext.alias === this.expression &&
-    !forContext.filters
-  ) {
     if (scope.$key) { // original is an object
       forContext.rawValue[scope.$key] = value
     } else {