vendor/assets/javascripts/clipboard.js in clipboard-rails-1.5.9 vs vendor/assets/javascripts/clipboard.js in clipboard-rails-1.5.10

- old
+ new

@@ -1,7 +1,7 @@ /*! - * clipboard.js v1.5.9 + * clipboard.js v1.5.10 * https://zenorocha.github.io/clipboard.js * * Licensed MIT © Zeno Rocha */ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Clipboard = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ @@ -432,18 +432,14 @@ this.selectedText = ''; }; ClipboardAction.prototype.initSelection = function initSelection() { - if (this.text && this.target) { - throw new Error('Multiple attributes declared, use either "target" or "text"'); - } else if (this.text) { + if (this.text) { this.selectFake(); } else if (this.target) { this.selectTarget(); - } else { - throw new Error('Missing required attributes, use either "target" or "text"'); } }; ClipboardAction.prototype.selectFake = function selectFake() { var _this = this; @@ -552,10 +548,18 @@ }, { key: 'target', set: function set(target) { if (target !== undefined) { if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) { + if (this.action === 'copy' && target.hasAttribute('disabled')) { + throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); + } + + if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) { + throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); + } + this._target = target; } else { throw new Error('Invalid "target" value, use a valid Element'); } } @@ -731,6 +735,6 @@ module.exports = Clipboard; }); },{"./clipboard-action":8,"good-listener":4,"tiny-emitter":7}]},{},[9])(9) -}); +}); \ No newline at end of file