File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ export default class Attribute {
44
44
} ,
45
45
46
46
set ( value ) : void {
47
- if ( ! value . hasOwnProperty ( 'isAttr' ) ) {
47
+ if ( ! value || ! value . hasOwnProperty ( 'isAttr' ) ) {
48
48
attr . setter ( this , value ) ;
49
49
}
50
50
}
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ let Author = Person.extend({
18
18
jsonapiType : 'authors'
19
19
} ,
20
20
21
+ nilly : attr ( ) ,
22
+
21
23
multiWords : hasMany ( 'multi_words' ) ,
22
24
books : hasMany ( ) ,
23
25
tags : hasMany ( ) ,
Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ describe('Model', function() {
14
14
type : 'authors' ,
15
15
attributes : {
16
16
firstName : 'Donald Budge' ,
17
- unknown : 'adsf'
17
+ unknown : 'adsf' ,
18
+ nilly : null
18
19
} ,
19
20
relationships : {
20
21
unknownrelationship : {
@@ -107,7 +108,8 @@ describe('Model', function() {
107
108
let instance = Model . fromJsonapi ( doc . data , doc ) ;
108
109
expect ( instance . firstName ) . to . eq ( 'Donald Budge' ) ;
109
110
expect ( instance . attributes ) . to . eql ( {
110
- firstName : 'Donald Budge'
111
+ firstName : 'Donald Budge' ,
112
+ nilly : null
111
113
} )
112
114
} ) ;
113
115
@@ -126,6 +128,11 @@ describe('Model', function() {
126
128
expect ( instance ) . to . not . have . property ( 'unknownrelationship' ) ;
127
129
} ) ;
128
130
131
+ it ( 'does not blow up on null attributes' , function ( ) {
132
+ let instance = Model . fromJsonapi ( doc . data , doc ) ;
133
+ expect ( instance . nilly ) . to . eq ( null ) ;
134
+ } ) ;
135
+
129
136
it ( 'assigns metadata correctly' , function ( ) {
130
137
let instance = Model . fromJsonapi ( doc . data , doc ) ;
131
138
expect ( instance . __meta__ ) . to . eql ( {
You can’t perform that action at this time.
0 commit comments