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 warning messages for default values #332

Merged
merged 1 commit into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions can-define.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ define.property = function(objPrototype, prop, definition, dataInitializers, com
//!steal-remove-start
// If value is an object or array, give a warning
if (definition.default !== null && typeof definition.default === 'object') {
canLogDev.warn("can-define: The value for " + prop + " is set to an object. This will be shared by all instances of the DefineMap. Use a function that returns the object instead.");
canLogDev.warn("can-define: The default value for " + prop + " is set to an object. This will be shared by all instances of the DefineMap. Use a function that returns the object instead.");
}
// If value is a constructor, give a warning
if (definition.default && canReflect.isConstructorLike(definition.default)) {
canLogDev.warn("can-define: The \"value\" for " + prop + " is set to a constructor. Did you mean \"Value\" instead?");
canLogDev.warn("can-define: The \"default\" for " + prop + " is set to a constructor. Did you mean \"Default\" instead?");
}
//!steal-remove-end

Expand Down
6 changes: 3 additions & 3 deletions map/map-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ canTestHelpers.devOnlyTest("log multiple property changes", function(assert) {
canTestHelpers.devOnlyTest("Setting a value with an object type generates a warning (#148)", function() {
QUnit.expect(1);

var message = "can-define: The value for options is set to an object. This will be shared by all instances of the DefineMap. Use a function that returns the object instead.";
var message = "can-define: The default value for options is set to an object. This will be shared by all instances of the DefineMap. Use a function that returns the object instead.";
var finishErrorCheck = canTestHelpers.willWarn(message);

//should issue a warning
Expand Down Expand Up @@ -1013,10 +1013,10 @@ canTestHelpers.devOnlyTest("Setting a value with an object type generates a warn
QUnit.equal(finishErrorCheck(), 2);
});

canTestHelpers.devOnlyTest("Setting a value to a constructor type generates a warning", function() {
canTestHelpers.devOnlyTest("Setting a default value to a constructor type generates a warning", function() {
QUnit.expect(1);

var message = "can-define: The \"value\" for options is set to a constructor. Did you mean \"Value\" instead?";
var message = "can-define: The \"default\" for options is set to a constructor. Did you mean \"Default\" instead?";
var finishErrorCheck = canTestHelpers.willWarn(message);

//should issue a warning
Expand Down