Merge pull request #4352 from matrix-org/t3chguy/fix_copy_without_code

Fix copy button on code blocks when there is no code tag just pre
This commit is contained in:
Michael Telatynski 2020-04-07 11:55:18 +01:00 committed by GitHub
commit 2a23ebdfcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -278,7 +278,7 @@ export default createReactClass({
const button = document.createElement("span");
button.className = "mx_EventTile_copyButton";
button.onclick = (e) => {
const copyCode = button.parentNode.getElementsByTagName("code")[0];
const copyCode = button.parentNode.getElementsByTagName("pre")[0];
const successful = this.copyToClipboard(copyCode.textContent);
const buttonRect = e.target.getBoundingClientRect();