Skip to content

Commit d9e92ff

Browse files
author
Vlad Balin
committed
fix for empty values in id-reference paths
1 parent 385bf10 commit d9e92ff

File tree

8 files changed

+16
-12
lines changed

8 files changed

+16
-12
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/traversable.js

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

lib/traversable.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.4",
3+
"version": "2.0.5",
44
"description": "Reactive serializable data layer for modern JS applications",
55
"main": "./dist/index.js",
66
"jsnext:main": "./lib/index.js",

src/traversable.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,16 @@ export class CompiledReference {
3535

3636
this.tail = splitTail && path.pop();
3737
this.local = !path.length;
38-
39-
path.unshift( 'self' );
4038

41-
this.resolve = <any> new Function( 'self', `return ${ path.join('.') };` );
39+
this.resolve = <any> new Function( 'self', `
40+
var v = self.${ path.shift() };
41+
42+
${ path.map( x => `
43+
v = v && v.${ x };
44+
`).join('')}
45+
46+
return v;
47+
` );
4248
}
4349
}
4450

tests/typescript/dist/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,7 @@ var CompiledReference = (function () {
882882
});
883883
this.tail = splitTail && path.pop();
884884
this.local = !path.length;
885-
path.unshift('self');
886-
this.resolve = new Function('self', "return " + path.join('.') + ";");
885+
this.resolve = new Function('self', "\n var v = self." + path.shift() + ";\n \n " + path.map(function (x) { return "\n v = v && v." + x + ";\n "; }).join('') + "\n\n return v;\n ");
887886
}
888887
return CompiledReference;
889888
}());

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)