diff --git a/assets/scripts/src/choices.js b/assets/scripts/src/choices.js index 1323dd3..a349692 100644 --- a/assets/scripts/src/choices.js +++ b/assets/scripts/src/choices.js @@ -117,7 +117,7 @@ export class Choices { if (!cuttingTheMustard) console.error('Choices: Your browser doesn\'t support Choices'); // Input type check - const canInit = this.passedElement && isElement(this.passedElement) && ['select-one', 'select-multiple', 'text'].includes(this.passedElement.type); + const canInit = this.passedElement && isElement(this.passedElement) && ['select-one', 'select-multiple', 'text'].some(type => type === this.passedElement.type); if(canInit) { // If element has already been initalised with Choices @@ -1434,7 +1434,7 @@ export class Choices { this.itemList.innerHTML = ''; // If we have items to add - if(itemListFragment.children.length) { + if(itemListFragment.children && itemListFragment.children.length) { // Update list this.itemList.appendChild(itemListFragment); } diff --git a/package.json b/package.json index 8781c89..c0a0ccb 100644 --- a/package.json +++ b/package.json @@ -37,9 +37,10 @@ "fuse.js": "^2.2.0", "jasmine-core": "^2.4.1", "karma": "^1.1.0", - "karma-chrome-launcher": "^1.0.1", "karma-coverage": "^1.0.0", + "karma-es6-shim": "^1.0.0", "karma-jasmine": "^1.0.2", + "karma-phantomjs-launcher": "^1.0.1", "karma-spec-reporter": "0.0.26", "karma-webpack": "^1.7.0", "node-sass": "^3.4.2", diff --git a/tests/karma.config.js b/tests/karma.config.js index 11d4f8d..354ea4b 100644 --- a/tests/karma.config.js +++ b/tests/karma.config.js @@ -6,8 +6,8 @@ module.exports = function(config) { files: [ '../tests/**/*_spec.js', ], - plugins: [webpack, 'karma-jasmine', 'karma-chrome-launcher', 'karma-coverage', 'karma-spec-reporter'], - browsers: ['Chrome'], + plugins: [webpack, 'karma-jasmine', 'karma-phantomjs-launcher', 'karma-coverage', 'karma-spec-reporter', 'es6-shim'], + browsers: ['PhantomJS'], preprocessors: { '**/*_spec.js': ['webpack'], 'src/**/*.js': ['webpack']