Skip to content

Releases: canjs/can-observable-mixin

v1.0.8

20 Apr 19:07
Compare
Choose a tag to compare

Code cleanup

#156

Set default to null / undefined without type

11 Dec 18:38
Compare
Choose a tag to 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

#154

Test fix for CanJS build

07 Nov 16:02
Compare
Choose a tag to compare

This fixes the test for type errors in order to make CanJS test suite pass.

Catch type errors only

01 Nov 17:45
Compare
Choose a tag to compare

This catchs can-type error to check the presence of .type property in order to use it for message improvements.

#149

Get update and updateDeep to work on list-like objects

23 Oct 18:15
Compare
Choose a tag to 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);

Enhance type error message

18 Oct 21:30
Compare
Choose a tag to 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.

#143

Fix weirdness with arrays

15 Oct 15:04
Compare
Choose a tag to 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.

#141

Type error message improvement

11 Oct 15:00
Compare
Choose a tag to 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.`

#140

Allow mixin types to dispatch events

30 Aug 20:58
Compare
Choose a tag to compare

Avoids use of ES Proxies when not supported.

22 Aug 03:27
Compare
Choose a tag to compare