我一直在使用带有SVG的DomSanitizer的html字符串.
在当前版本的Angular之前,这个工作得很好:
this.domSanitizer.bypassSecurityTrustHtml(content);
现在我得到一个叫做的对象
SafeHtmlImpl {changingThisBreaksApplicationSecurity: "<svg> blah </svg>"}
changingThisBreaksApplicationSecurity
Run Code Online (Sandbox Code Playgroud)
现在是否有新的方法来访问DomSanitizer的输出?我应该以SafeHTML类型或其他方式接收它吗?如果它仍然过滤html,那么拥有bypassSecurityTrustHtml有什么意义呢?
明信片上的任何答案?请...
有谁知道是否可以使用 Chrome 扩展 API 查看从 Service Worker 缓存提供的 Web 请求?
目前,从 Service Worker 提供的 Web 请求看起来很像从浏览器缓存提供的请求 - 它们实际上对 Chrome Web 请求 API 不可见。
我可以使用页面中的内容脚本来读取 navigator.serviceWorker。也许我可以清除 Service Worker 的缓存以确保 Web 请求随后被外部获取...
扩展的另一部分使用此代码发送消息后
chrome.runtime.sendMessage({greeting: "hello"});
Run Code Online (Sandbox Code Playgroud)
任何可以使用此消息传递API的Rx.js专家
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
console.log(sender.tab ?
"from a content script:" + sender.tab.url :
"from the extension");
if (request.greeting == "hello")
sendResponse({farewell: "goodbye"});
});
Run Code Online (Sandbox Code Playgroud)
并将其包装在发出新消息并允许sendResponse的Observable中?
简单地将传入消息作为Observable发出非常容易。
const MessagingObservable = Rx.Observable.create(observer => {
chrome.runtime.onMessage.addListener(listener);
function listener(request, sender, sendResponse) {
observer.next(request);
}
return () => {
chrome.runtime.onMessage.removeListener(listener);
};
});
Run Code Online (Sandbox Code Playgroud)
但是如何绑定sendResponse回调?