clipboard.js: Name conflict on chrome 61+
Chrome version 61 has added a Clipboard object, i still can’t find any documentation on this new object: on the console:
window.Clipboard
ƒ Clipboard() { [native code] }
Now when this plugin is loaded on a page it overwrittes de original definition of Chrome I don’t know if it has any impact yet, may be this plugin could take a new name to avoid conflicts?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 20
- Comments: 38 (1 by maintainers)
Commits related to this issue
- Fix name collision for Chrome 61+ (#468); * breaking change * * quick work-around for name collision with new Chrome clipboard API * NOTE: this breaks the former API, renaming all instances of "Clip... — committed to rivy/js.ClipboardJS by rivy 6 years ago
- Clipboard.js update hotfix; see https://github.com/zenorocha/clipboard.js/issues/468 — committed to 747/vsselector by 747 6 years ago
- clipboard: Update clipboard to v2.0.0 to avoid variable name conflict. It turns out, now we have a new standard way to access clipboard by `Clipboard` method and currently this conflict with the cons... — committed to zulip/zulip by priyank-p 6 years ago
- clipboard: Update clipboard to v2.0.0 to avoid variable name conflict. It turns out, now we have a new standard way to access clipboard by `Clipboard` method and currently this conflict with the cons... — committed to shubham-padia/zulip by priyank-p 6 years ago
- Clipboard.js update hotfix; see https://github.com/zenorocha/clipboard.js/issues/468 — committed to 747/vsselector by 747 6 years ago
For backward compatibility, you could make both variables available (
Clipboard
andClipboardJS
for example). Pushing the idea forward, you could even add a method to restore the originalClipboard
value after initialisation. LikejQuery.noConflict()
does, restoring the initial value of$
and still being accessible withjQuery
.EDIT: Underscore.js provides the same utility: http://underscorejs.org/#noConflict. So does Lodash: https://lodash.com/docs/#noConflict.
I’m having the same issue.
Uncaught TypeError: Illegal constructor
When calling
new Clipboard
Only happens on Chrome 61
@jimcaven You’re probably still doing
new Clipboard
in ur code; you neednew ClipboardJS
with the new version.In the meanwhile, you can install a modified, working copy from my fork…
[ClipboardJS v2.0.1 CDN] @ https://cdn.rawgit.com/rivy/js.ClipboardJS/021e74439d7d64da9e44bbfb488850ed7a4dadf4/dist/clipboard.min.js
It’s labeled as “v2.0.1” because it’s a breaking change, renaming all instances of “Clipboard” and “ClipboardAction” to “ClipboardJS” and “ClipboardJSAction”, respectively. Change your code accordingly and it should be working correctly again, even in the most recent browser versions.
Hmm. So @zenorocha should consider to change it to ClipboardJS or simular. @zenorocha do you want a PR for this?
Shouldn’t this result in a 2.0 release? You can’t overwrite
window.Clipboard
if Chrome provides a native implementation because the interfaces are not compatible. You also can’t just do nothing since doing so breaks anyone’s code who depends on clipboard.js. Both these approaches lead to breakage. I think moving forward, yes, the name of the constructor absolutely should be changed to something else (e.g.ClipboardJS
).@mAAdhaTTah I think it’s part of the Asynchronous Clipboard API.
navigator.clipboard
is supposed to return aClipboard
object (though it doesn’t work currently AFAICT. I think Chrome has started implementing it.I am using the latest CDN (https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js) and still seeing the Illegal constructor error…
Running latest Chrome: Version 64.0.3282.186 (Official Build) (64-bit)
Could old versions be cached or something?
Hey everybody,
Sorry for taking so long to fix this. A 2.0.0 release has been published with the proper fix.
https://github.com/zenorocha/clipboard.js/releases/tag/v2.0.0
Unfortunately this is a breaking change that is not backwards compatible.