CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 1
Releases: canjs/can-observable-mixin
v1.0.8
Compare
Assets 2
Set default to null / undefined without type
Compare
This fixes setting property value to null
or undefined
, for example:
class Foo extends ObservableObject() {
static get props() {
return {
nullProp: { default: null },
undefinedProp: { default: undefined }
};
}
}
var foo = new Foo();
foo.nullProp // -> null
foo.undefinedProp // -> undefined
and
class Foo extends ObservableObject() {
static get props() {
return {
nullProp: null ,
undefinedProp: undefined
};
}
}
var foo = new Foo();
foo.nullProp // -> null
foo.undefinedProp // -> undefined
Assets 2
Test fix for CanJS build
Compare
This fixes the test for type errors in order to make CanJS test suite pass.
Assets 2
Catch type errors only
Compare
This catchs can-type
error to check the presence of .type
property in order to use it for message improvements.
Assets 2
Get update and updateDeep to work on list-like objects
Compare
This patch release fixes .update
and updateDeep
behavior when called on list-like objects.
The following code was throwing an exception due to both methods always calling canReflect.updateMap
and canReflect.updateDeepMap
under the hood even if the caller was an array.
class MyArray extends mixinMapProps(Array) {}
let arr = new MyArray();
arr.push(1, 2, 3, 4);
assert.equal(arr.length, 4);
arr.updateDeep([]); // throws an exception
assert.equal(arr.length, 0);
Assets 2
Enhance type error message
Compare
This enhance type error message by adding the value type in the message:
Before:
farah.age = '4'; // -> Uncaught Error: 4 is not of type Number. Property age is using "type: Number". Use "age: type.convert(Number)" to automatically convert values to Numbers when setting the "age" property.
`
Now:
farah.age = '4'; // -> Uncaught Error: "4" (string) is not of type Number. Property age is using "type: Number". Use "age: type.convert(Number)" to automatically convert values to Numbers when setting the "age" property.
Assets 2
Fix weirdness with arrays
Compare
list
property will have Array
type with an example like the following:
class Foo extends mixinObject() {
static get props() {
return {
list: []
};
}
}
var foo = new Foo();
foo.list = [ "one", "two" ];
TypeError: Right-hand side of 'instanceof'
error will not be thrown.
Assets 2
Type error message improvement
Compare
This improve the error message bu suggestion to use type.convert
for the right type:
class Person extends mixinObject() {
static get props() {
return {
age: type.check(Number)
};
}
}
var farah = new Person();
farah.age = '4'; // -> `Uncaught Error: 4 is not of type Number. Property age is using "type: Number". Use "age: type.convert(Number)" to automatically convert values to Numbers when setting the "age" property.`