Move the _addCodeElement() call down a bit

We can skip this if the first if statement is true

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
pull/21833/head
Šimon Brandner 2021-02-23 07:46:03 +01:00
parent c965119410
commit c9baff1e10
No known key found for this signature in database
GPG Key ID: 9760693FDD98A790
1 changed files with 4 additions and 2 deletions

View File

@ -96,11 +96,13 @@ export default class TextualBody extends React.Component {
const pres = ReactDOM.findDOMNode(this).getElementsByTagName("pre"); const pres = ReactDOM.findDOMNode(this).getElementsByTagName("pre");
if (pres.length > 0) { if (pres.length > 0) {
for (let i = 0; i < pres.length; i++) { for (let i = 0; i < pres.length; i++) {
// Add code element if it's missing
if (!pres[i].getElementsByTagName("code")[0]) this._addCodeElement(pres[i]);
// If there already is a div wrapping the codeblock we want to skip this. // If there already is a div wrapping the codeblock we want to skip this.
// This happens after the codeblock was edited. // This happens after the codeblock was edited.
if (pres[i].parentNode.className == "mx_EventTile_pre_container") continue; if (pres[i].parentNode.className == "mx_EventTile_pre_container") continue;
// Add code element if it's missing
if (!pres[i].getElementsByTagName("code")[0]) {
this._addCodeElement(pres[i]);
}
// Wrap a div around <pre> so that the copy button can be correctly positioned // Wrap a div around <pre> so that the copy button can be correctly positioned
// when the <pre> overflows and is scrolled horizontally. // when the <pre> overflows and is scrolled horizontally.
const div = this._wrapInDiv(pres[i]); const div = this._wrapInDiv(pres[i]);