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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy