Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in 2.0.9 leading to values other than type string (number, boolean) cannot be copied #873

Open
tasso94 opened this issue Mar 25, 2024 · 2 comments
Labels

Comments

@tasso94
Copy link

tasso94 commented Mar 25, 2024

🐛 Bug Report

See the following example:

new ClipboardJS(document.getElementsByClassName("btn"), {
  text: function() {
    return 900;
  }
});

Expected Behaviour

When text() returns another value type than string, no error is shown and value is stored in the clipboard.

Actual Behaviour

When text() returns another value type than string, the following error is shown:

Uncaught TypeError: element.hasAttribute is not a function
    at select (clipboard.js:717:1)
    at ClipboardActionCopy (clipboard.js:117:1)
    at ClipboardActionDefault (clipboard.js:166:1)
    at Clipboard.onClick (clipboard.js:290:1)
    at HTMLAnchorElement.<anonymous> (clipboard.js:278:1)

To Reproduce

Check out the following JS Riddle: https://jsfiddle.net/L6ptjo7w/

Browsers Affected

I tested it on Chrome 123.

Operational System

Mac OS Ventura.

@obetomuniz
Copy link
Collaborator

Thanks for reporting this @tasso94. And thanks to provide a reproducible environment. I'm planning to contribute to some open issues soon. I will be triaging it. Thanks again.

@tasso94
Copy link
Author

tasso94 commented Jun 26, 2024

Hi @obetomuniz,

That would be awesome. Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants