Skip to content

Commit f4f76fd

Browse files
author
Alain Bourgeois
committed
Make outline manager resilient to missing legacy outline mount
1 parent 9471402 commit f4f76fd

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/outline/manager.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,22 @@ export default function (context) {
521521
* @returns {HTMLElement}
522522
*/
523523
function getOrCreateContainer (id) {
524+
if (id === 'outline') {
525+
const existingOutline = document.getElementById('outline')
526+
if (existingOutline) {
527+
return existingOutline
528+
}
529+
530+
const outlineHost = document.getElementById('OutlineView')
531+
if (outlineHost) {
532+
const outlineTable = document.createElement('table')
533+
outlineTable.id = 'outline'
534+
outlineTable.style.width = '100%'
535+
outlineHost.appendChild(outlineTable)
536+
return outlineTable
537+
}
538+
}
539+
524540
return (
525541
document.getElementById(id) ||
526542
(() => {
@@ -2242,7 +2258,7 @@ export default function (context) {
22422258
@param table -- option -- a table element in which to put the outline.
22432259
*/
22442260
this.GotoSubject = function (subject, expand, pane, solo, referrer, table) {
2245-
table = table || dom.getElementById('outline') // if does not exist just add one? nowhere to out it
2261+
table = table || getOutlineContainer() // if does not exist create a compatible host in the current shell
22462262
if (solo) {
22472263
UI.utils.emptyNode(table)
22482264
table.style.width = '100%'

0 commit comments

Comments
 (0)