File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -1519,7 +1519,10 @@ function store(Model, options = {}) {
1519
1519
}
1520
1520
1521
1521
const resolveId = options . id
1522
- ? options . id
1522
+ ? ( host ) => {
1523
+ const id = options . id ( host ) ;
1524
+ return id !== undefined && id !== null ? String ( id ) : undefined ;
1525
+ }
1523
1526
: ( host , value ) => {
1524
1527
if ( value !== null && value !== undefined ) {
1525
1528
return typeof value === "object" ? value . id : String ( value ) ;
Original file line number Diff line number Diff line change @@ -1215,6 +1215,9 @@ describe("store:", () => {
1215
1215
byundefined : store ( Model , { id : ( ) => undefined } ) ,
1216
1216
byprop : store ( Model , { id : "modelId" } ) ,
1217
1217
byfn : store ( Model , { id : ( { modelId } ) => modelId } ) ,
1218
+ byfnwithnumber : store ( Model , {
1219
+ id : ( { modelId } ) => Number ( modelId ) ,
1220
+ } ) ,
1218
1221
withoutid : store ( Model ) ,
1219
1222
draft : store ( Model , { draft : true , id : "modelId" } ) ,
1220
1223
draftwithoutid : store ( Model , { draft : true } ) ,
@@ -1256,6 +1259,11 @@ describe("store:", () => {
1256
1259
} ) ;
1257
1260
} ) ;
1258
1261
1262
+ fit ( "gets a model instance when id is a number zero" , ( ) => {
1263
+ el . modelId = "0" ;
1264
+ expect ( el . byfnwithnumber ) . toBe ( store . get ( Model , "0" ) ) ;
1265
+ } ) ;
1266
+
1259
1267
describe ( "in draft mode" , ( ) => {
1260
1268
it ( "throws when try to set value by assertion" , ( ) => {
1261
1269
expect ( ( ) => {
You can’t perform that action at this time.
0 commit comments