Skip to content

Commit 2ac2798

Browse files
authored
Merge pull request #383 from wuerthcs/bugfix/NODEJS-633-cannot-read-property-executor
Fix for NODEJS-633
1 parent 7701031 commit 2ac2798

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/mapping/tree.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ class Tree extends Node {
109109
this._onItemAdded();
110110
return value;
111111
}
112+
if (node.value === null && node.edges.length > 0) {
113+
node.value = valueHandler();
114+
}
112115
return node.value;
113116
}
114117

test/unit/mapping/tree-tests.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ describe('Tree', function () {
6767
const k = assertNode(j.edges[0], [ 'k' ], 8, 1);
6868
assertNode(k.edges[0], [ 'l' ], 6, 0);
6969
});
70+
71+
it('should set value if a node not a leaf and it is a match', () => {
72+
const tree = new Tree();
73+
tree.getOrCreate(['a', 'b', 'c'], () => true);
74+
tree.getOrCreate(['a', 'b', 'd'], () => true);
75+
assert.strictEqual(tree.getOrCreate(['a', 'b'], () => true), true);
76+
});
77+
7078
});
7179
});
7280

0 commit comments

Comments
 (0)