Skip to content

Commit

Permalink
Fixed element detection by checking fragment before and after decodin…
Browse files Browse the repository at this point in the history
…g if necessary (#141848)
  • Loading branch information
Balastrong committed Feb 1, 2022
1 parent 71a20bb commit c713056
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/webview/browser/pre/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ const handleInnerClick = (event) => {
if (node.getAttribute('href') === '#') {
event.view.scrollTo(0, 0);
} else if (node.hash && (node.getAttribute('href') === node.hash || (baseElement && node.href === baseElement.href + node.hash))) {
const fragment = node.hash.substr(1, node.hash.length - 1);
const scrollTarget = event.view.document.getElementById(decodeURIComponent(fragment));
const fragment = node.hash.slice(1);
const scrollTarget = event.view.document.getElementById(fragment) ?? event.view.document.getElementById(decodeURIComponent(fragment));
scrollTarget?.scrollIntoView();
} else {
hostMessaging.postMessage('did-click-link', node.href.baseVal || node.href);
Expand Down

0 comments on commit c713056

Please sign in to comment.