diff --git a/src/annotation/lineAnnotation.js b/src/annotation/lineAnnotation.js index 424f574761..fa6739c7dd 100644 --- a/src/annotation/lineAnnotation.js +++ b/src/annotation/lineAnnotation.js @@ -42,8 +42,7 @@ var lineAnnotation = function (args) { line: function (d) { /* Return an array that has the same number of items as we have * vertices. */ - return Array.apply(null, Array(m_this.options('vertices').length)).map( - function () { return d; }); + return Array(m_this.options('vertices').length).fill(d); }, position: function (d, i) { return m_this.options('vertices')[i]; @@ -53,8 +52,7 @@ var lineAnnotation = function (args) { line: function (d) { /* Return an array that has the same number of items as we have * vertices. */ - return Array.apply(null, Array(m_this.options('vertices').length)).map( - function () { return d; }); + return Array(m_this.options('vertices').length).fill(d); }, position: function (d, i) { return m_this.options('vertices')[i]; diff --git a/src/annotation/polygonAnnotation.js b/src/annotation/polygonAnnotation.js index 0e8df9947e..337d2782bc 100644 --- a/src/annotation/polygonAnnotation.js +++ b/src/annotation/polygonAnnotation.js @@ -43,7 +43,9 @@ var polygonAnnotation = function (args) { return new polygonAnnotation(args); } - args = util.deepMerge({}, this.constructor.defaults, { + var m_this = this; + + args = util.deepMerge({ style: { polygon: function (d) { return d.polygon; } }, @@ -52,12 +54,11 @@ var polygonAnnotation = function (args) { const coord = m_this._coordinates(); /* Return an array that has the same number of items as we have * vertices. */ - return Array.apply(null, Array((coord.outer || coord).length)).map( - function () { return d; }); + return Array((coord.outer || coord).length).fill(d); }, position: function (d, i) { if (d.x !== undefined) { - return d.x; + return d; } return m_this.options('vertices')[i]; } @@ -65,13 +66,12 @@ var polygonAnnotation = function (args) { cursorStyle: { position: util.identityFunction } - }, args); + }, this.constructor.defaults, args); args.vertices = args.vertices || args.coordinates || []; delete args.coordinates; annotation.call(this, 'polygon', args); - var m_this = this, - s_actions = this.actions, + var s_actions = this.actions, s_state = this.state; /** diff --git a/src/util/common.js b/src/util/common.js index 065980688d..5f2c9e3d3e 100644 --- a/src/util/common.js +++ b/src/util/common.js @@ -1011,15 +1011,15 @@ var util = { } const copy = source[key]; if (copy && typeof copy === 'object' && (copy.constructor === Object || Array.isArray(copy))) { - let src = target[key]; + let value = target[key]; if (!Array.isArray(copy)) { - if (typeof src !== 'object' || Array.isArray(src)) { - src = {}; + if (typeof value !== 'object' || Array.isArray(value)) { + value = {}; } - } else if (!Array.isArray(src)) { - src = []; + } else if (!Array.isArray(value)) { + value = []; } - target[key] = util.deepMerge(src, copy); + target[key] = util.deepMerge(value, copy); } else if (copy !== undefined) { target[key] = copy; }