diff --git a/.eslintrc b/.eslintrc index b872545..a1c6094 100644 --- a/.eslintrc +++ b/.eslintrc @@ -6,4 +6,5 @@ rules: indent: [2, 4, {SwitchCase: 1}] quotes: [2, 'single'] dot-notation: [2, {allowKeywords: false}] + no-console: 0 no-prototype-builtins: 0 diff --git a/index.js b/index.js index 4c8016f..3a4a652 100644 --- a/index.js +++ b/index.js @@ -108,7 +108,7 @@ Ycb.prototype = { return; } var value = context[depth]; - if(value.constructor !== Array) { + if(!Array.isArray(value)) { var keys = this.precedenceMap[value]; var n = keys.length; for(var j=0; j1.0" }, "devDependencies": { - "eslint": "^6.0.1", + "eslint": "^5.0.0", "mocha": "^6.1.4", "nyc": "^14.1.1" }, diff --git a/tests/unit/index.js b/tests/unit/index.js index f18b9de..b947160 100644 --- a/tests/unit/index.js +++ b/tests/unit/index.js @@ -61,6 +61,14 @@ describe('ycb unit tests', function () { cmp([0,6,9], ycb._parseContext({flavor:'bt', region:'ir'})); cmp([2,7,8], ycb._parseContext({lang:'fr_FR', region:'fr', flavor:'att'})); }); + it('should handle an undefined context value', function () { + var bundle, ycb; + bundle = readFixtureFile('dimensions.json') + .concat(readFixtureFile('simple-1.json')) + .concat(readFixtureFile('simple-3.json')); + ycb = new libycb.Ycb(bundle); + cmp([0, 0, 0], ycb._parseContext({ region: undefined })); + }); }); describe('_processRawBundle', function () {