Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dev code for webpack compatibility #119

Merged
merged 1 commit into from
Jun 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 32 additions & 22 deletions can-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ var Control = Construct.extend("Control",
context.called = name;
return method.apply(context, [wrapped].concat(slice.call(arguments, 0)));
}
//!steal-remove-start
Object.defineProperty(controlMethod, "name", {
value: canReflect.getName(this) + "["+name+"]",
});
//!steal-remove-end
return controlMethod;
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
Object.defineProperty(controlMethod, "name", {
value: canReflect.getName(this) + "["+name+"]",
});
}
//!steal-remove-end
return controlMethod;
},

// ## can.Control._isAction
Expand Down Expand Up @@ -201,11 +203,13 @@ var Control = Construct.extend("Control",
};
};

//!steal-remove-start
Object.defineProperty(controlActionData, "name", {
value: canReflect.getName(controlInstance || this.prototype) + "["+methodName+"].actionData",
});
//!steal-remove-end
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
Object.defineProperty(controlActionData, "name", {
value: canReflect.getName(controlInstance || this.prototype) + "["+methodName+"].actionData",
});
}
//!steal-remove-end

readyCompute = new Observation(controlActionData, this);

Expand All @@ -221,19 +225,23 @@ var Control = Construct.extend("Control",
actionData.parts[2], actionData.parts[1], methodName, controlInstance);
};

//!steal-remove-start
Object.defineProperty(handler, "name", {
value: canReflect.getName(controlInstance) + "["+methodName+"].handler",
});
//!steal-remove-end
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
Object.defineProperty(handler, "name", {
value: canReflect.getName(controlInstance) + "["+methodName+"].handler",
});
}
//!steal-remove-end


canReflect.onValue(readyCompute, handler, "mutate");
//!steal-remove-start
if(unableToBind) {
dev.log('can-control: No property found for handling ' + methodName);
}
//!steal-remove-end
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
if(unableToBind) {
dev.log('can-control: No property found for handling ' + methodName);
}
}
//!steal-remove-end

controlInstance._bindings.readyComputes[methodName] = {
compute: readyCompute,
Expand Down Expand Up @@ -440,7 +448,9 @@ var Control = Construct.extend("Control",
destroy: function () {
if (this.element === null) {
//!steal-remove-start
dev.warn("can-control: Control already destroyed");
if(process.env.NODE_ENV !== 'production') {
dev.warn("can-control: Control already destroyed");
}
//!steal-remove-end
return;
}
Expand Down