Skip to content

Commit 9087cc6

Browse files
author
Vlad Balin
committed
Hotfix for collections of models with empty string id
1 parent c75a647 commit 9087cc6

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/collection/commons.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/collection/commons.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "type-r",
3-
"version": "2.0.3",
3+
"version": "2.0.4",
44
"description": "Reactive serializable data layer for modern JS applications",
55
"main": "./dist/index.js",
66
"jsnext:main": "./lib/index.js",

src/collection/commons.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export function addIndex( index : IdIndex, model : Record ) : void {
124124
index[ model.cid ] = model;
125125
var id = model.id;
126126

127-
if( id != null ){
127+
if( id || id === 0 ){
128128
index[ id ] = model;
129129
}
130130
}
@@ -133,7 +133,7 @@ export function addIndex( index : IdIndex, model : Record ) : void {
133133
export function removeIndex( index : IdIndex, model : Record ) : void {
134134
delete index[ model.cid ];
135135
var id = model.id;
136-
if( id != null ){
136+
if( id || id === 0 ){
137137
delete index[ id ];
138138
}
139139
}

tests/typescript/dist/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,14 +2525,14 @@ function sortElements(collection, options) {
25252525
function addIndex(index, model) {
25262526
index[model.cid] = model;
25272527
var id = model.id;
2528-
if (id != null) {
2528+
if (id || id === 0) {
25292529
index[id] = model;
25302530
}
25312531
}
25322532
function removeIndex(index, model) {
25332533
delete index[model.cid];
25342534
var id = model.id;
2535-
if (id != null) {
2535+
if (id || id === 0) {
25362536
delete index[id];
25372537
}
25382538
}

tests/typescript/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)