mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-10-16 16:15:45 -04:00
slightly faster attachment of clipboard.js to DOM
This commit is contained in:
1 file changed
+2
-2
@@ -14,8 +14,9 @@ if (ClipboardJS.isSupported()) {
|
||||
|
||||
// insert button as a sibling to Hugo's code fence
|
||||
highlightDiv.insertBefore(button, highlightDiv.firstChild);
|
||||
});
|
||||
|
||||
new ClipboardJS(button, {
|
||||
new ClipboardJS("button.copy-button", {
|
||||
text: (trigger) => {
|
||||
// actual code element will (should) have class "language-*", even if plaintext
|
||||
const fenceElement = trigger.parentElement.querySelector('code[class^="language-"]'); // eslint-disable-line quotes
|
||||
@@ -34,5 +35,4 @@ if (ClipboardJS.isSupported()) {
|
||||
// text needed to be auto-selected to copy, unselect immediately
|
||||
e.clearSelection();
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user