未验证 提交 6fcec00d 编写于 作者: J John Keech 提交者: GitHub

Clear out stale CSS style properties on webview (#96665)

Fixes #96621
上级 996b5be2
......@@ -197,8 +197,21 @@
}
if (initData.styles) {
const documentStyle = document.documentElement.style;
// Remove stale properties
for (let i = documentStyle.length - 1; i >= 0; i--) {
const property = documentStyle[i];
// Don't remove properties that the webview might have added separately
if (property && property.startsWith('--vscode-')) {
documentStyle.removeProperty(property);
}
}
// Re-add new properties
for (const variable of Object.keys(initData.styles)) {
document.documentElement.style.setProperty(`--${variable}`, initData.styles[variable]);
documentStyle.setProperty(`--${variable}`, initData.styles[variable]);
}
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册