Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9af9c29

Browse filesBrowse files
committed
wathcer: improve warning check for two-way bindings for v-for with filters (close vuejs#1433)
1 parent 58d0228 commit 9af9c29
Copy full SHA for 9af9c29

File tree

1 file changed

+17
-8
lines changed
Filter options

1 file changed

+17
-8
lines changed

‎src/watcher.js

Copy file name to clipboardExpand all lines: src/watcher.js
+17-8Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,26 @@ Watcher.prototype.set = function (value) {
145145
}
146146
// two-way sync for v-for alias
147147
var forContext = scope.$forContext
148-
if (forContext && forContext.alias === this.expression) {
149-
if (forContext.filters) {
150-
process.env.NODE_ENV !== 'production' && _.warn(
148+
if (process.env.NODE_ENV !== 'production') {
149+
if (
150+
forContext &&
151+
forContext.filters &&
152+
(new RegExp(forContext.alias + '\\b')).test(this.expression)
153+
) {
154+
_.warn(
151155
'It seems you are using two-way binding on ' +
152-
'a v-for alias, and the v-for has filters. ' +
153-
'This will not work properly. Either remove the ' +
154-
'filters or use an array of objects and bind to ' +
155-
'object properties instead.'
156+
'a v-for alias (' + this.expression + '), and the ' +
157+
'v-for has filters. This will not work properly. ' +
158+
'Either remove the filters or use an array of ' +
159+
'objects and bind to object properties instead.'
156160
)
157-
return
158161
}
162+
}
163+
if (
164+
forContext &&
165+
forContext.alias === this.expression &&
166+
!forContext.filters
167+
) {
159168
if (scope.$key) { // original is an object
160169
forContext.rawValue[scope.$key] = value
161170
} else {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.