Skip to content

Commit

Permalink
Merge branch 'Dinistro-issue53'
Browse files Browse the repository at this point in the history
  • Loading branch information
ocombe committed Mar 19, 2016
2 parents 28eda37 + 8200127 commit 4a52e50
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bundles/ng2-translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ System.registerDynamic("src/translate.parser", [], true, function($__require, ex
key = '';
do {
key += keys.shift();
if (target[key]) {
if (target[key] && (typeof target[key] === 'object' || !keys.length)) {
target = target[key];
key = '';
} else if (!keys.length) {
Expand Down
2 changes: 1 addition & 1 deletion src/translate.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Parser {
key = '';
do {
key += keys.shift();
if (target[key]) {
if (target[key] && (typeof target[key] === 'object' || !keys.length)) {
target = target[key];
key = '';
} else if (!keys.length) {
Expand Down
4 changes: 4 additions & 0 deletions tests/translate.parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export function main() {
expect(parser.getValue({key1: {'key2.key3': "value3"}}, 'key1.key2.key3')).toEqual("value3");
expect(parser.getValue({'key1.key2.key3': "value3"}, 'key1.key2.key3')).toEqual("value3");
expect(parser.getValue({'key1.key2': {key3: "value3"}}, 'key1.key2.keyWrong')).not.toBeDefined();
expect(parser.getValue({
'key1': "value1",
'key1.key2' : "value2"
}, 'key1.key2')).toEqual("value2");

});
});
Expand Down

0 comments on commit 4a52e50

Please sign in to comment.