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'.
|
* Sets the `action` to be performed which can be either 'copy' or 'cut'.
|
||||||
* @param {String} action
|
* @param {String} action
|
||||||
*/
|
*/
|
||||||
set action(action) {
|
set action(action = 'copy') {
|
||||||
this._action = action || 'copy';
|
this._action = action;
|
||||||
|
|
||||||
if (this._action !== 'copy' && this._action !== 'cut') {
|
if (this._action !== 'copy' && this._action !== 'cut') {
|
||||||
throw new Error('Invalid "action" value, use either "copy" or "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.
|
* or a custom function that was passed in the constructor.
|
||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
*/
|
*/
|
||||||
resolveOptions(options) {
|
resolveOptions(options = {}) {
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
this.action = (typeof options.action === 'function') ? options.action : this.setAction;
|
this.action = (typeof options.action === 'function') ? options.action : this.setAction;
|
||||||
this.target = (typeof options.target === 'function') ? options.target : this.setTarget;
|
this.target = (typeof options.target === 'function') ? options.target : this.setTarget;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user