browser: fix broken inline clipboard buttons after IE11 refactor #452

This commit is contained in:
Sören Weber 2023-02-04 22:50:19 +01:00
parent 6b96c2d662
commit 6d90be3015
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -335,8 +335,7 @@ function initCodeClipboard(){
for( var i = 0; i < codeElements.length; i++ ){
var code = codeElements[i];
var text = code.textContent;
var parent = code.parentNode;
var inPre = parent.tagName.toLowerCase() == 'pre';
var inPre = code.parentNode.tagName.toLowerCase() == 'pre';
if( inPre || text.length > 5 ){
var clip = new ClipboardJS( '.copy-to-clipboard-button', {
@ -382,7 +381,7 @@ function initCodeClipboard(){
var span = document.createElement( 'span' );
span.classList.add( 'copy-to-clipboard' );
span.appendChild( clone );
parent.replaceChild( span, code );
code.parentNode.replaceChild( span, code );
code = clone;
}
var button = document.createElement( 'span' );
@ -394,7 +393,7 @@ function initCodeClipboard(){
this.removeAttribute( 'aria-label' );
this.classList.remove( 'tooltipped', 'tooltipped-w', 'tooltipped-se', 'tooltipped-sw' );
});
parent.insertBefore( button, code.nextSibling );
code.parentNode.insertBefore( button, code.nextSibling );
}
}
}