javascript - CSP 规则以不同方式应用于 Firefox 中的 SVG
问题描述
我有带有内容安全策略的 HTML 文档。
<meta http-equiv="Content-Security-Policy" content="style-src 'self'">
我创建 SVG 元素,设置style
属性并将元素附加到文档中。
const el = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
el.style.background = 'green';
document.body.appendChild(el);
在 Firefox 中,我收到内容安全策略错误,并且未应用样式。Chrome 中没有错误。Firefox 中的 DIV 元素没有错误。
这种行为是预期的还是实现错误?
下面的演示应该在 Chrome 中显示两个绿色框。在 Firefox 中,右边的框是红色的。
解决方案
推荐阅读
- javascript - Next.js 通过路径渲染动态内容
- reactjs - axios在reactJS中获取请求
- windows - 如果我使用 runas /netonly 运行 powershell,我如何才能看到“netonly”用户
- excel - 清除所有没有颜色的单元格
- powershell - 如何授权 GAS 编辑 Google 电子表格的范围
- r - 如何修复文件中的错误(文件,“rt”):无法打开连接
- php - 使用 PHP cURL 查看 Twitter 主页
- r - 从不同数据框的同一列中获取5之间的共同值
- javascript - 在我的应用程序之外使用 javascript 播放音频
- url - 如何在 Sass 中使用 @use 谷歌字体 URL?