Skip to content

Commit

Permalink
Merge pull request #133 from canjs/fix-webpack-debug-style
Browse files Browse the repository at this point in the history
fix dev code for webpack compatibility
  • Loading branch information
Mohamed Cherif Bouchelaghem authored Jun 27, 2018
2 parents f59bd7e + 412ae6b commit d8b6f24
Showing 1 changed file with 57 additions and 39 deletions.
96 changes: 57 additions & 39 deletions can-observation.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,19 @@ function Observation(func, context, options){

// Add debugging names.
//!steal-remove-start
this.onDependencyChange[getChangesSymbol] = function getChanges() {
return {
valueDependencies: new Set([self])
if (process.env.NODE_ENV !== 'production') {
this.onDependencyChange[getChangesSymbol] = function getChanges() {
return {
valueDependencies: new Set([self])
};
};
};
Object.defineProperty(this.onDependencyChange, "name", {
value: canReflect.getName(this) + ".onDependencyChange",
});
Object.defineProperty(this.update, "name", {
value: canReflect.getName(this) + ".update",
});
Object.defineProperty(this.onDependencyChange, "name", {
value: canReflect.getName(this) + ".onDependencyChange",
});
Object.defineProperty(this.update, "name", {
value: canReflect.getName(this) + ".update",
});
}
//!steal-remove-end
}

Expand Down Expand Up @@ -84,25 +86,35 @@ canReflect.assign(Observation.prototype, {
// observables have had time to notify all observables that "derive" their value.
dependencyChange: function(context, args){
if(this.bound === true) {
// Update this observation after all `notify` tasks have been run.
queues.deriveQueue.enqueue(
var queuesArgs = [];
queuesArgs = [
this.update,
this,
[],
{
priority: this.options.priority
//!steal-remove-start
}
];
//!steal-remove-start
if (process.env.NODE_ENV !== 'production') {
queuesArgs = [
this.update,
this,
[],
{
priority: this.options.priority
/* jshint laxcomma: true */
, log: [ canReflect.getName(this.update) ]
/* jshint laxcomma: false */
}
/* jshint laxcomma: true */
, log: [ canReflect.getName(this.update) ]
, [canReflect.getName(context), "changed"]
/* jshint laxcomma: false */
//!steal-remove-end
}
//!steal-remove-start
/* jshint laxcomma: true */
, [canReflect.getName(context), "changed"]
/* jshint laxcomma: false */
//!steal-remove-end
);
];
}
//!steal-remove-end
// Update this observation after all `notify` tasks have been run.
queues.deriveQueue.enqueue.apply(queues.deriveQueue, queuesArgs);
}
},
// Called to update its value as part of the `derive` queue.
Expand Down Expand Up @@ -176,21 +188,23 @@ canReflect.assign(Observation.prototype, {
*/
log: function() {
//!steal-remove-start
var quoteString = function quoteString(x) {
return typeof x === "string" ? JSON.stringify(x) : x;
};
this._log = function(previous, current) {
dev.log(
canReflect.getName(this),
"\n is ", quoteString(current),
"\n was ", quoteString(previous)
);
};
if (process.env.NODE_ENV !== 'production') {
var quoteString = function quoteString(x) {
return typeof x === "string" ? JSON.stringify(x) : x;
};
this._log = function(previous, current) {
dev.log(
canReflect.getName(this),
"\n is ", quoteString(current),
"\n was ", quoteString(previous)
);
};
}
//!steal-remove-end
}
});

canReflect.assignSymbols(Observation.prototype, {
var observationProto = {
"can.getValue": Observation.prototype.get,
"can.isValueLike": true,
"can.isMapLike": false,
Expand Down Expand Up @@ -220,13 +234,17 @@ canReflect.assignSymbols(Observation.prototype, {
},
"can.setPriority": function(priority){
this.options.priority = priority;
},
//!steal-remove-start
"can.getName": function() {
return canReflect.getName(this.constructor) + "<" + canReflect.getName(this.func) + ">";
}
//!steal-remove-end
});
};

//!steal-remove-start
if (process.env.NODE_ENV !== 'production') {
observationProto["can.getName"] = function() {
return canReflect.getName(this.constructor) + "<" + canReflect.getName(this.func) + ">";
};
}
//!steal-remove-end
canReflect.assignSymbols(Observation.prototype, observationProto);

// ## Observation.updateChildrenAndSelf
// This recursively checks if an observation's dependencies might be in the `derive` queue.
Expand Down

0 comments on commit d8b6f24

Please sign in to comment.