Skip to content

Commit f59a85f

Browse files
authored
Set type="button" attribute for copy to clipboard plugin. (#2593)
When using Prism + copy to clipboard inside a HTML form, the form is submitted when copying. It's because by default the button is seen as a submit button. Adding the `type="button"` attribute prevents this.
1 parent b04cbaf commit f59a85f

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

plugins/copy-to-clipboard/prism-copy-to-clipboard.js

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
Prism.plugins.toolbar.registerButton('copy-to-clipboard', function (env) {
3939
var linkCopy = document.createElement('button');
4040
linkCopy.textContent = 'Copy';
41+
linkCopy.setAttribute('type', 'button');
4142

4243
var element = env.element;
4344

plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)