diff --git a/package.json b/package.json index 6773ad8..ab60c89 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "babel-eslint": "^8.2.2", "babel-loader": "^7.1.3", "babel-plugin-add-module-exports": "^0.2.1", + "babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-preset-env": "^1.6.1", "copy-webpack-plugin": "^4.5.1", "css-loader": "^0.28.10", diff --git a/src/common/constants.js b/src/common/constants.js index d83f7b5..3d33643 100644 --- a/src/common/constants.js +++ b/src/common/constants.js @@ -41,4 +41,4 @@ export const POPOVER_HTML = ` `; export const OVERLAY_HTML = `
`; -export const STAGE_HTML = ``; \ No newline at end of file +export const STAGE_HTML = ``; diff --git a/src/index.js b/src/index.js index 954acf6..5040369 100644 --- a/src/index.js +++ b/src/index.js @@ -24,7 +24,7 @@ export default class Driver { * @param {Object} options */ constructor(options = {}) { - this.options = Object.assign({ + this.options = { animate: OVERLAY_ANIMATE, // Whether to animate or not opacity: OVERLAY_OPACITY, // Overlay opacity padding: OVERLAY_PADDING, // Spacing around the element from the overlay @@ -35,7 +35,8 @@ export default class Driver { }, onDeselected: () => { // When the element has been deselected }, - }, options); + ...options, + }; this.document = document; this.window = window; @@ -244,11 +245,10 @@ export default class Driver { querySelector = currentStep; } else { querySelector = currentStep.element; - elementOptions = Object.assign( - {}, - this.options, - currentStep, - ); + elementOptions = { + ...this.options, + ...currentStep, + }; } const domElement = this.document.querySelector(querySelector); @@ -259,17 +259,14 @@ export default class Driver { let popover = null; if (elementOptions.popover && elementOptions.popover.description) { - const popoverOptions = Object.assign( - {}, - this.options, - elementOptions.popover, - { - totalCount: allSteps.length, - currentIndex: index, - isFirst: index === 0, - isLast: index === allSteps.length - 1, - }, - ); + const popoverOptions = { + ...this.options, + ...elementOptions.popover, + totalCount: allSteps.length, + currentIndex: index, + isFirst: index === 0, + isLast: index === allSteps.length - 1, + }; popover = new Popover(popoverOptions, this.window, this.document); } diff --git a/webpack.config.dev.js b/webpack.config.dev.js index 1228d87..43f7b3a 100644 --- a/webpack.config.dev.js +++ b/webpack.config.dev.js @@ -18,23 +18,26 @@ module.exports = { }, module: { rules: [ - // { - // test: /\.js$/, - // exclude: /node_modules/, - // loader: 'eslint-loader', - // enforce: 'pre', - // options: { - // failOnWarning: false, - // failOnError: true, - // }, - // }, + { + test: /\.js$/, + exclude: /node_modules/, + loader: 'eslint-loader', + enforce: 'pre', + options: { + failOnWarning: false, + failOnError: true, + }, + }, { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', options: { presets: ['env'], - plugins: ['babel-plugin-add-module-exports'], + plugins: [ + 'babel-plugin-add-module-exports', + 'transform-object-rest-spread', + ], }, }, { diff --git a/webpack.config.prod.js b/webpack.config.prod.js index 682dcfd..848826b 100644 --- a/webpack.config.prod.js +++ b/webpack.config.prod.js @@ -32,7 +32,10 @@ module.exports = { loader: 'babel-loader', options: { presets: ['env'], - plugins: ['babel-plugin-add-module-exports'], + plugins: [ + 'babel-plugin-add-module-exports', + 'transform-object-rest-spread', + ], }, }, { diff --git a/yarn.lock b/yarn.lock index 3f7a3a0..98b8aeb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -833,7 +833,7 @@ babel-plugin-transform-flow-strip-types@^6.8.0: babel-plugin-syntax-flow "^6.18.0" babel-runtime "^6.22.0" -babel-plugin-transform-object-rest-spread@^6.22.0: +babel-plugin-transform-object-rest-spread@^6.22.0, babel-plugin-transform-object-rest-spread@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz#0f36692d50fef6b7e2d4b3ac1478137a963b7b06" dependencies: