mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
using default parameters instead the 'or' approach
This commit is contained in:
parent
b5bc00f2e4
commit
14baab7386
@ -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"');
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user