[6a3a178] | 1 | 'use strict';
|
---|
| 2 | /**
|
---|
| 3 | * @license Angular v12.0.0-next.0
|
---|
| 4 | * (c) 2010-2020 Google LLC. https://angular.io/
|
---|
| 5 | * License: MIT
|
---|
| 6 | */
|
---|
| 7 | /**
|
---|
| 8 | * @license
|
---|
| 9 | * Copyright Google LLC All Rights Reserved.
|
---|
| 10 | *
|
---|
| 11 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 12 | * found in the LICENSE file at https://angular.io/license
|
---|
| 13 | */
|
---|
| 14 | Zone.__load_patch('ResizeObserver', (global, Zone, api) => {
|
---|
| 15 | const ResizeObserver = global['ResizeObserver'];
|
---|
| 16 | if (!ResizeObserver) {
|
---|
| 17 | return;
|
---|
| 18 | }
|
---|
| 19 | const resizeObserverSymbol = api.symbol('ResizeObserver');
|
---|
| 20 | api.patchMethod(global, 'ResizeObserver', (delegate) => (self, args) => {
|
---|
| 21 | const callback = args.length > 0 ? args[0] : null;
|
---|
| 22 | if (callback) {
|
---|
| 23 | args[0] = function (entries, observer) {
|
---|
| 24 | const zones = {};
|
---|
| 25 | const currZone = Zone.current;
|
---|
| 26 | for (let entry of entries) {
|
---|
| 27 | let zone = entry.target[resizeObserverSymbol];
|
---|
| 28 | if (!zone) {
|
---|
| 29 | zone = currZone;
|
---|
| 30 | }
|
---|
| 31 | let zoneEntriesInfo = zones[zone.name];
|
---|
| 32 | if (!zoneEntriesInfo) {
|
---|
| 33 | zones[zone.name] = zoneEntriesInfo = { entries: [], zone: zone };
|
---|
| 34 | }
|
---|
| 35 | zoneEntriesInfo.entries.push(entry);
|
---|
| 36 | }
|
---|
| 37 | Object.keys(zones).forEach(zoneName => {
|
---|
| 38 | const zoneEntriesInfo = zones[zoneName];
|
---|
| 39 | if (zoneEntriesInfo.zone !== Zone.current) {
|
---|
| 40 | zoneEntriesInfo.zone.run(callback, this, [zoneEntriesInfo.entries, observer], 'ResizeObserver');
|
---|
| 41 | }
|
---|
| 42 | else {
|
---|
| 43 | callback.call(this, zoneEntriesInfo.entries, observer);
|
---|
| 44 | }
|
---|
| 45 | });
|
---|
| 46 | };
|
---|
| 47 | }
|
---|
| 48 | return args.length > 0 ? new ResizeObserver(args[0]) : new ResizeObserver();
|
---|
| 49 | });
|
---|
| 50 | api.patchMethod(ResizeObserver.prototype, 'observe', (delegate) => (self, args) => {
|
---|
| 51 | const target = args.length > 0 ? args[0] : null;
|
---|
| 52 | if (!target) {
|
---|
| 53 | return delegate.apply(self, args);
|
---|
| 54 | }
|
---|
| 55 | let targets = self[resizeObserverSymbol];
|
---|
| 56 | if (!targets) {
|
---|
| 57 | targets = self[resizeObserverSymbol] = [];
|
---|
| 58 | }
|
---|
| 59 | targets.push(target);
|
---|
| 60 | target[resizeObserverSymbol] = Zone.current;
|
---|
| 61 | return delegate.apply(self, args);
|
---|
| 62 | });
|
---|
| 63 | api.patchMethod(ResizeObserver.prototype, 'unobserve', (delegate) => (self, args) => {
|
---|
| 64 | const target = args.length > 0 ? args[0] : null;
|
---|
| 65 | if (!target) {
|
---|
| 66 | return delegate.apply(self, args);
|
---|
| 67 | }
|
---|
| 68 | let targets = self[resizeObserverSymbol];
|
---|
| 69 | if (targets) {
|
---|
| 70 | for (let i = 0; i < targets.length; i++) {
|
---|
| 71 | if (targets[i] === target) {
|
---|
| 72 | targets.splice(i, 1);
|
---|
| 73 | break;
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 | target[resizeObserverSymbol] = undefined;
|
---|
| 78 | return delegate.apply(self, args);
|
---|
| 79 | });
|
---|
| 80 | api.patchMethod(ResizeObserver.prototype, 'disconnect', (delegate) => (self, args) => {
|
---|
| 81 | const targets = self[resizeObserverSymbol];
|
---|
| 82 | if (targets) {
|
---|
| 83 | targets.forEach((target) => {
|
---|
| 84 | target[resizeObserverSymbol] = undefined;
|
---|
| 85 | });
|
---|
| 86 | self[resizeObserverSymbol] = undefined;
|
---|
| 87 | }
|
---|
| 88 | return delegate.apply(self, args);
|
---|
| 89 | });
|
---|
| 90 | });
|
---|