MCPcopy Index your code
hub / github.com/angular/angular / patchBrowser

Function patchBrowser

packages/zone.js/lib/browser/browser.ts:31–331  ·  view source on GitHub ↗
(Zone: ZoneType)

Source from the content-addressed store, hash-verified

29import {propertyDescriptorPatch} from './property-descriptor';
30
31export function patchBrowser(Zone: ZoneType): void {
32 Zone.__load_patch('timers', (global: any) => {
33 const set = 'set';
34 const clear = 'clear';
35 patchTimer(global, set, clear, 'Timeout');
36 patchTimer(global, set, clear, 'Interval');
37 patchTimer(global, set, clear, 'Immediate');
38 });
39
40 Zone.__load_patch('requestAnimationFrame', (global: any) => {
41 patchTimer(global, 'request', 'cancel', 'AnimationFrame');
42 patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame');
43 patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame');
44 });
45
46 Zone.__load_patch('blocking', (global: any, Zone: ZoneType) => {
47 const blockingMethods = ['alert', 'prompt', 'confirm'];
48 for (let i = 0; i < blockingMethods.length; i++) {
49 const name = blockingMethods[i];
50 patchMethod(global, name, (delegate, symbol, name) => {
51 return function (s: any, args: any[]) {
52 return Zone.current.run(delegate, global, args, name);
53 };
54 });
55 }
56 });
57
58 Zone.__load_patch('EventTarget', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
59 patchEvent(global, api);
60 eventTargetPatch(global, api);
61 // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener
62 const XMLHttpRequestEventTarget = (global as any)['XMLHttpRequestEventTarget'];
63 if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) {
64 api.patchEventTarget(global, api, [XMLHttpRequestEventTarget.prototype]);
65 }
66 });
67
68 Zone.__load_patch('MutationObserver', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
69 patchClass('MutationObserver');
70 patchClass('WebKitMutationObserver');
71 });
72
73 Zone.__load_patch('IntersectionObserver', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
74 patchClass('IntersectionObserver');
75 });
76
77 Zone.__load_patch('FileReader', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
78 patchClass('FileReader');
79 });
80
81 Zone.__load_patch('on_property', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
82 propertyDescriptorPatch(api, global);
83 });
84
85 Zone.__load_patch('customElements', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
86 patchCustomElements(global, api);
87 });
88

Callers 2

rollup-main.tsFile · 0.90
rollup-mix.tsFile · 0.90

Calls 13

patchTimerFunction · 0.90
patchMethodFunction · 0.90
patchEventFunction · 0.90
eventTargetPatchFunction · 0.90
patchClassFunction · 0.90
propertyDescriptorPatchFunction · 0.90
patchCustomElementsFunction · 0.90
patchPrototypeFunction · 0.90
patchQueueMicrotaskFunction · 0.90
patchXHRFunction · 0.85
__load_patchMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…