From 5ab50475e0b17fb9d02c70544d2ec72796550b17 Mon Sep 17 00:00:00 2001 From: Gabriel Kalani Date: Wed, 3 May 2017 01:34:18 -0300 Subject: [PATCH] ES6 refactor (#409) * little fix * little fix /2 * test/clipboard.js refactored * emitter: emitter --> emitter * Examples in ES6 * es6 * back to original code * script > npm test * script > npm test not necessary * updating modules * removing export default --- package.json | 40 ++++++++++++++++++++-------------------- src/clipboard-action.js | 2 +- src/clipboard.js | 2 +- test/clipboard-action.js | 4 ++-- test/clipboard.js | 6 +++--- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index 31a784e..9c7be05 100644 --- a/package.json +++ b/package.json @@ -11,31 +11,31 @@ "cut" ], "dependencies": { - "good-listener": "^1.2.0", + "good-listener": "^1.2.2", "select": "^1.1.2", - "tiny-emitter": "^1.0.0" + "tiny-emitter": "^2.0.0" }, "devDependencies": { - "babel-cli": "^6.5.1", - "babel-core": "^6.5.2", - "babel-plugin-transform-es2015-modules-umd": "^6.5.0", - "babel-preset-es2015": "^6.5.0", - "babelify": "^7.2.0", + "babel-cli": "^6.24.1", + "babel-core": "^6.24.1", + "babel-plugin-transform-es2015-modules-umd": "^6.24.1", + "babel-preset-es2015": "^6.24.1", + "babelify": "^7.3.0", "bannerify": "Vekat/bannerify#feature-option", - "browserify": "^13.0.0", - "chai": "^3.4.1", - "install": "^0.8.1", - "karma": "^1.3.0", - "karma-browserify": "^5.0.1", + "browserify": "^14.3.0", + "chai": "^3.5.0", + "install": "^0.9.6", + "karma": "^1.6.0", + "karma-browserify": "^5.1.1", "karma-chai": "^0.1.0", - "karma-mocha": "^1.2.0", - "karma-phantomjs-launcher": "^1.0.0", - "karma-sinon": "^1.0.4", - "mocha": "^3.1.2", - "phantomjs-prebuilt": "^2.1.4", - "sinon": "^1.17.2", - "uglify-js": "^2.4.24", - "watchify": "^3.4.0" + "karma-mocha": "^1.3.0", + "karma-phantomjs-launcher": "^1.0.4", + "karma-sinon": "^1.0.5", + "mocha": "^3.3.0", + "phantomjs-prebuilt": "^2.1.14", + "sinon": "^2.2.0", + "uglify-js": "^2.8.22", + "watchify": "^3.9.0" }, "scripts": { "build": "npm run build-debug && npm run build-min", diff --git a/src/clipboard-action.js b/src/clipboard-action.js index 732ee61..aa5e3ad 100644 --- a/src/clipboard-action.js +++ b/src/clipboard-action.js @@ -64,7 +64,7 @@ class ClipboardAction { this.fakeElem.style[ isRTL ? 'right' : 'left' ] = '-9999px'; // Move element to the same position vertically let yPosition = window.pageYOffset || document.documentElement.scrollTop; - this.fakeElem.style.top = yPosition + 'px'; + this.fakeElem.style.top = `${yPosition}px`; this.fakeElem.setAttribute('readonly', ''); this.fakeElem.value = this.text; diff --git a/src/clipboard.js b/src/clipboard.js index 76e9d1f..c8417fc 100644 --- a/src/clipboard.js +++ b/src/clipboard.js @@ -52,7 +52,7 @@ class Clipboard extends Emitter { action : this.action(trigger), target : this.target(trigger), text : this.text(trigger), - trigger : trigger, + trigger, emitter : this }); } diff --git a/test/clipboard-action.js b/test/clipboard-action.js index e746bee..d749233 100644 --- a/test/clipboard-action.js +++ b/test/clipboard-action.js @@ -141,7 +141,7 @@ describe('ClipboardAction', () => { }); let clip = new ClipboardAction({ - emitter: emitter, + emitter, target: document.querySelector('#input') }); }); @@ -156,7 +156,7 @@ describe('ClipboardAction', () => { }); let clip = new ClipboardAction({ - emitter: emitter, + emitter, target: document.querySelector('#input') }); }); diff --git a/test/clipboard.js b/test/clipboard.js index bc1569d..77e0214 100644 --- a/test/clipboard.js +++ b/test/clipboard.js @@ -26,7 +26,7 @@ describe('Clipboard', () => { describe('#resolveOptions', () => { before(() => { - global.fn = function() {}; + global.fn = () => {}; }); it('should set action as a function', () => { @@ -79,8 +79,8 @@ describe('Clipboard', () => { it('should throw an exception when target is invalid', done => { try { - var clipboard = new Clipboard('.btn', { - target: function() { + const clipboard = new Clipboard('.btn', { + target() { return null; } });