diff --git a/src/helpers/helpers.core.js b/src/helpers/helpers.core.js index 852119fe824..c975cb0fb66 100644 --- a/src/helpers/helpers.core.js +++ b/src/helpers/helpers.core.js @@ -1,5 +1,9 @@ 'use strict'; +function isValidKey(key) { + return ['__proto__', 'prototype', 'constructor'].indexOf(key) === -1; +} + /** * @namespace Chart.helpers */ @@ -196,7 +200,7 @@ var helpers = { * @private */ _merger: function(key, target, source, options) { - if (['__proto__', 'prototype', 'constructor'].indexOf(key) !== -1) { + if (!isValidKey(key)) { // We want to ensure we do not copy prototypes over // as this can pollute global namespaces return; @@ -217,6 +221,12 @@ var helpers = { * @private */ _mergerIf: function(key, target, source) { + if (!isValidKey(key)) { + // We want to ensure we do not copy prototypes over + // as this can pollute global namespaces + return; + } + var tval = target[key]; var sval = source[key];