…this matches browsers' native behaviour.
Unified · Split
| @@ -353,6 +353,16 @@ $.lockScroll = function (el, fn) { · 352 unmodified lines | |||
| 353 | } | 353 | } |
| 354 | }; | 354 | }; |
| 355 | 355 | ||
| 356 | // If `el` is inside any `<details>` elements, expand them. | ||
| 357 | $.openDetailsAncestors = function (el) { | ||
| 358 | while (el) { | ||
| 359 | if (el.tagName === "DETAILS") { | ||
| 360 | el.open = true; | ||
| 361 | } | ||
| 362 | el = el.parentElement; | ||
| 363 | } | ||
| 364 | } | ||
| 365 | |||
| 356 | let smoothScroll = | 366 | let smoothScroll = |
| 357 | (smoothStart = | 367 | (smoothStart = |
| 358 | smoothEnd = | 368 | smoothEnd = |
| @@ -114,6 +114,7 @@ app.views.Content = class Content extends app.View { · 113 unmodified lines | |||
| 114 | $.scrollToWithImageLock(el, this.scrollEl, "top", { | 114 | $.scrollToWithImageLock(el, this.scrollEl, "top", { |
| 115 | margin: this.scrollEl === this.el ? 0 : $.offset(this.el).top, | 115 | margin: this.scrollEl === this.el ? 0 : $.offset(this.el).top, |
| 116 | }); | 116 | }); |
| 117 | $.openDetailsAncestors(el); | ||
| 117 | $.highlight(el, { className: "_highlight" }); | 118 | $.highlight(el, { className: "_highlight" }); |
| 118 | } else { | 119 | } else { |
| 119 | this.scrollTo(this.scrollMap[this.routeCtx.state.id]); | 120 | this.scrollTo(this.scrollMap[this.routeCtx.state.id]); |