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.
This commit is contained in:
Richard Hansen 2021-07-29 01:22:44 -04:00
parent 0c963a817a
commit 9fda5adcef

View file

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