prism: Uncaught TypeError: Illegal constructor Error
Hi,
I am getting this error:
Uncaught TypeError: Illegal constructor
at n (prism.js:1)
at prism.js:1
at prism.js:1
at Array.forEach (<anonymous>)
at Prism.plugins.toolbar.hook (prism.js:1)
at Object.run (prism.js:1)
at Object.highlightElement (prism.js:1)
at HTMLDocument.highlightAll (prism.js:1)
It seems to be showing when I add the “Copy to Clipboard Button” package.
My browser I am getting the error is Google Chrome Version 62.0.3200.0 (Official Build)
Here is a screenshot of the error in dev tools:

For now I am just going to live with out adding this plugin. I thought I’d let you know anyway.
p.s. Normal setup works fine no problem. It only appears with this plugin addon.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 7
- Comments: 18 (8 by maintainers)
Commits related to this issue
- Copy to clipboard: Get around name conflict in Chrome v61+ Fixes #1181 — committed to Golmote/prism by Golmote 7 years ago
- Reset Clipboard to undefined if native code Chrome now ships with a window.Clipboard built in, which breaks this check. This ensures we're not grabbing the built-in Clipboard and definitely have the ... — committed to mAAdhaTTah/prism by mAAdhaTTah 7 years ago
- Reset Clipboard to undefined if native code Chrome now ships with a window.Clipboard built in, which breaks this check. This ensures we're not grabbing the built-in Clipboard and definitely have the ... — committed to mAAdhaTTah/prism by mAAdhaTTah 7 years ago
- Reset Clipboard to undefined if native code (#1206) Chrome now ships with a window.Clipboard built in, which breaks this check. This ensures we're not grabbing the built-in Clipboard and definitely... — committed to PrismJS/prism by mAAdhaTTah 7 years ago
This version of the fix is here: #1206.
@caraya Thanks, that might be it, but Chrome 61 (or 63) doesn’t have a
navigator.clipboardproperty. I’m still not sure the cause.Update: Yes, the
window.Clipboardprototype matches the Clipboard inteface in the spec, so this must be an early introduction as they build out the infra for this Clipboard api.Just so everyone knows, this can be resolved by including Clipboard.js yourself, either in a script tag or bundled into your JS. It’s specifically the plugin’s behavior to fallback to a CDN version if it doesn’t find Clipboard.js that is failing.
@ayumihamsaki Anything after 61 will have this problem, as that’s when the global
Clipboardobject was introduced. The plugin normally installs Clipboard.js at runtime for you, if you don’t install it yourself, but with the introduction ofwindow.Clipboardin Chrome 61, this check fails, aswindow.Clipboardalready exists. It’s just not theClipboard.jsinstance we’re expecting here.