replace mutation observer with dom#asDomUri, #75061

This commit is contained in:
Johannes Rieken
2019-07-04 10:19:40 +02:00
parent 7c88e07cc6
commit 7980cd2697
13 changed files with 50 additions and 107 deletions

View File

@@ -14,6 +14,8 @@ import { Emitter, Event } from 'vs/base/common/event';
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import * as platform from 'vs/base/common/platform';
import { coalesce } from 'vs/base/common/arrays';
import { URI } from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network';
export function clearNode(node: HTMLElement): void {
while (node.firstChild) {
@@ -1181,3 +1183,23 @@ export function animate(fn: () => void): IDisposable {
let stepDisposable = scheduleAtNextAnimationFrame(step);
return toDisposable(() => stepDisposable.dispose());
}
const _location = URI.parse(window.location.href);
export function asDomUri(uri: URI): URI {
if (!uri) {
return uri;
}
if (!platform.isWeb) {
//todo@joh remove this once we have sw in electron going
return uri;
}
if (Schemas.vscodeRemote === uri.scheme) {
// rewrite vscode-remote-uris to uris of the window location
// so that they can be intercepted by the service worker
return _location.with({ path: '/vscode-resources/fetch', query: uri.toString() });
}
return uri;
}