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:

untitled

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

Most upvoted comments

This version of the fix is here: #1206.

@caraya Thanks, that might be it, but Chrome 61 (or 63) doesn’t have a navigator.clipboard property. I’m still not sure the cause.

Update: Yes, the window.Clipboard prototype 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 Clipboard object was introduced. The plugin normally installs Clipboard.js at runtime for you, if you don’t install it yourself, but with the introduction of window.Clipboard in Chrome 61, this check fails, as window.Clipboard already exists. It’s just not the Clipboard.js instance we’re expecting here.