using default parameters instead the 'or' approach

This commit is contained in:
rspecht 2015-09-29 18:36:07 -03:00
parent b5bc00f2e4
commit 14baab7386
2 changed files with 3 additions and 4 deletions

View File

@ -140,8 +140,8 @@ class ClipboardAction {
* Sets the `action` to be performed which can be either 'copy' or 'cut'.
* @param {String} action
*/
set action(action) {
this._action = action || 'copy';
set action(action = 'copy') {
this._action = action;
if (this._action !== 'copy' && this._action !== 'cut') {
throw new Error('Invalid "action" value, use either "copy" or "cut"');

View File

@ -27,8 +27,7 @@ class Clipboard extends Emitter {
* or a custom function that was passed in the constructor.
* @param {Object} options
*/
resolveOptions(options) {
options = options || {};
resolveOptions(options = {}) {
this.action = (typeof options.action === 'function') ? options.action : this.setAction;
this.target = (typeof options.target === 'function') ? options.target : this.setTarget;