Skip to content

Commit

Permalink
Merge pull request #179 from canjs/can-observation-value
Browse files Browse the repository at this point in the history
Set can-observation._value instead of .value
  • Loading branch information
chasenlehara committed Jul 4, 2018
2 parents 0acd544 + 11d3cdd commit f5cbdef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"Map": true
},
"strict": false,
"validthis": true,
"curly": true,
"eqeqeq": true,
"freeze": true,
Expand Down
17 changes: 14 additions & 3 deletions scope-key-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ var ScopeKeyData = function(scope, key, options){

valueEventBindings(ScopeKeyData.prototype);

function fastOnBoundSet_Value() {
this._value = this.newVal;
}

function fastOnBoundSetValue() {
this.value = this.newVal;
}

Object.assign(ScopeKeyData.prototype, {
constructor: ScopeKeyData,
dispatch: function dispatch(newVal){
Expand Down Expand Up @@ -174,9 +182,12 @@ Object.assign(ScopeKeyData.prototype, {

return Observation.prototype.dependencyChange.apply(this, arguments);
};
observation.onBound = function(){
this.value = this.newVal;
};

if (observation.hasOwnProperty("_value")) {// can-observation 4.1+
observation.onBound = fastOnBoundSet_Value;
} else {// can-observation < 4.1
observation.onBound = fastOnBoundSetValue;
}
},
toSlowPath: function(){
this.observation.dependencyChange = Observation.prototype.dependencyChange;
Expand Down

0 comments on commit f5cbdef

Please sign in to comment.