Skip to content

Commit

Permalink
Log when encountering invalid json in vscode-context
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Jul 27, 2022
1 parent 8f25356 commit 3098951
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1070,8 +1070,10 @@
}

try {
context = { ...JSON.parse(el.getAttribute('data-vscode-context')), ...context };
} catch {}
context = { ...JSON.parse(el.dataset.vscodeContext), ...context };
} catch (e) {
console.error(`Error parsing 'data-vscode-context' as json`, el, e)
}

el = el.parentElement;
}
Expand Down
8 changes: 5 additions & 3 deletions src/vs/workbench/contrib/webview/browser/pre/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8">

<meta http-equiv="Content-Security-Policy"
content="default-src 'none'; script-src 'sha256-31a+qtoOhPC136ibtip6gpqSiW72yo48kmtxyi0Qptc=' 'self'; frame-src 'self'; style-src 'unsafe-inline';">
content="default-src 'none'; script-src 'sha256-JpX/ganPoxpavjxWCz9DUZgwVZ59o2lwSYTQrziPsdU=' 'self'; frame-src 'self'; style-src 'unsafe-inline';">

<!-- Disable pinch zooming -->
<meta name="viewport"
Expand Down Expand Up @@ -1071,8 +1071,10 @@
}

try {
context = { ...JSON.parse(el.getAttribute('data-vscode-context')), ...context };
} catch {}
context = { ...JSON.parse(el.dataset.vscodeContext), ...context };
} catch (e) {
console.error(`Error parsing 'data-vscode-context' as json`, el, e)
}

el = el.parentElement;
}
Expand Down

0 comments on commit 3098951

Please sign in to comment.