|
@@ -62,18 +62,19 @@ p._bind = function (def) {
|
|
|
if (this.bind) {
|
|
if (this.bind) {
|
|
|
this.bind()
|
|
this.bind()
|
|
|
}
|
|
}
|
|
|
- if (
|
|
|
|
|
- this.update && this._watcherExp &&
|
|
|
|
|
- (!this.isLiteral || this._isDynamicLiteral) &&
|
|
|
|
|
- !this._checkStatement()
|
|
|
|
|
- ) {
|
|
|
|
|
|
|
+ if (this._watcherExp &&
|
|
|
|
|
+ (this.update || this.twoWay) &&
|
|
|
|
|
+ (!this.isLiteral || this._isDynamicLiteral) &&
|
|
|
|
|
+ !this._checkStatement()) {
|
|
|
// wrapped updater for context
|
|
// wrapped updater for context
|
|
|
var dir = this
|
|
var dir = this
|
|
|
- var update = this._update = function (val, oldVal) {
|
|
|
|
|
- if (!dir._locked) {
|
|
|
|
|
- dir.update(val, oldVal)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ var update = this._update = this.update
|
|
|
|
|
+ ? function (val, oldVal) {
|
|
|
|
|
+ if (!dir._locked) {
|
|
|
|
|
+ dir.update(val, oldVal)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ : function () {} // noop if no update is provided
|
|
|
// use raw expression as identifier because filters
|
|
// use raw expression as identifier because filters
|
|
|
// make them different watchers
|
|
// make them different watchers
|
|
|
var watcher = this.vm._watchers[this.raw]
|
|
var watcher = this.vm._watchers[this.raw]
|
|
@@ -97,7 +98,7 @@ p._bind = function (def) {
|
|
|
this._watcher = watcher
|
|
this._watcher = watcher
|
|
|
if (this._initValue != null) {
|
|
if (this._initValue != null) {
|
|
|
watcher.set(this._initValue)
|
|
watcher.set(this._initValue)
|
|
|
- } else {
|
|
|
|
|
|
|
+ } else if (this.update) {
|
|
|
this.update(watcher.value)
|
|
this.update(watcher.value)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|