diff --git a/CHANGELOG.md b/CHANGELOG.md index 4caa96a..8ea1fb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # ChangeLog +## 2019-11-02 Version 2.1.1 +* fix undefined key with root level array. + ## 2019-11-02 Version 2.1.1 * Wrong array conversion when brackets are used (Reported by vladshcherbin #27) diff --git a/bower.json b/bower.json index f82525f..e3686db 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "dot-object", - "version": "2.1.1", + "version": "2.1.2", "description": "dot-object makes it possible to transform and read (JSON) objects using dot notation.", "main": "dist/dot-object.js", "authors": [ diff --git a/dist/dot-object.js b/dist/dot-object.js index 58114f0..208a405 100644 --- a/dist/dot-object.js +++ b/dist/dot-object.js @@ -512,7 +512,8 @@ ) ) { if (isArray && this.useBrackets) { - return this.dot(obj[key], tgt, path.slice(0, -1).concat(path[path.length - 1] + index)) + var previousKey = path[path.length - 1] || '' + return this.dot(obj[key], tgt, path.slice(0, -1).concat(previousKey + index)) } else { return this.dot(obj[key], tgt, path.concat(index)) } diff --git a/dist/dot-object.min.js b/dist/dot-object.min.js index 4ddab83..356a592 100644 --- a/dist/dot-object.min.js +++ b/dist/dot-object.min.js @@ -1 +1 @@ -!function(t){"use strict";function s(t,r){var e,i;if("function"==typeof r)void 0!==(i=r(t))&&(t=i);else if(Array.isArray(r))for(e=0;e