ace2_inner.js: Improve discovery of `sidediv` and `linemetricsdiv`

The `Node.nextSibling` property returns the next Node, not the next
Element. If whitespace, an HTML comment, or any other type of
non-Element Node is ever introduced between the Elements then
`.nextSibling` no longer returns the desired Element. Switching to
`Element.nextElementSibling` would work, but finding the Elements by
ID is more readable and future-proof.
pull/5124/head
Richard Hansen 2021-07-29 01:22:44 -04:00
parent 0c963a817a
commit 9fda5adcef
1 changed files with 3 additions and 3 deletions

View File

@ -60,10 +60,10 @@ function Ace2Inner(editorInfo, cssManagers) {
window.focus();
};
const iframe = window.frameElement;
const outerWin = window.parent;
const sideDiv = iframe.nextSibling;
const lineMetricsDiv = sideDiv.nextSibling;
const outerDoc = outerWin.document;
const sideDiv = outerDoc.getElementById('sidediv');
const lineMetricsDiv = outerDoc.getElementById('linemetricsdiv');
let lineNumbersShown;
let sideDivInner;