Clipboard.js: Copying empty text to clipboard throws javascript error.

Created on 10 Dec 2015  路  3Comments  路  Source: zenorocha/clipboard.js

I was trying to replace ZeroClipboard with this new clipboard.js library to get rid of the flash dependancy, but I felt this one workflow was unsupported with this library. An example of this is showcased here: https://jsfiddle.net/o6g9gu2w/. When trying to copy empty text, due to user input being empty, I get the following error: Missing required attributes, use either "target" or "text" caused by the following line https://github.com/zenorocha/clipboard.js/blob/d9254459b791785ab3a50c3d13524ba07ea307bb/src/clipboard-action.js#L45. I would like to know if there is a way for me to catch or prevent this error or how this could be fixed. This is the only thing preventing me from switching to this library.

question

All 3 comments

Hey @dweepcan,

Some sort of string needs to be returned, so we can include a space if input is empty.
https://jsfiddle.net/zenorocha/o6g9gu2w/4/

Let me know if you have any other problems.

@zenorocha But this means that whatever was previously in the clipboard is destroyed which might be unexpected/annoying for the user.

Fixed at https://github.com/zenorocha/clipboard.js/commit/7a5a910bcd83aa44718dc30caea503d9da37d4b9. Please use v1.5.10 in order to benefit from this.

Was this page helpful?
0 / 5 - 0 ratings