@atlaskit/react-ufo 4.10.0 → 4.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/cjs/interaction-metrics/index.js +6 -4
- package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +14 -16
- package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/get-mutated-elements.js +50 -0
- package/dist/es2019/interaction-metrics/index.js +6 -4
- package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +11 -11
- package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/get-mutated-elements.js +27 -0
- package/dist/esm/interaction-metrics/index.js +6 -4
- package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +14 -16
- package/dist/esm/vc/vc-observer-new/viewport-observer/utils/get-mutated-elements.js +43 -0
- package/dist/types/common/common/types.d.ts +1 -0
- package/dist/types/create-interaction-extra-metrics-payload/index.d.ts +1 -0
- package/dist/types/create-payload/index.d.ts +384 -0
- package/dist/types/interaction-metrics/index.d.ts +2 -2
- package/dist/types/vc/vc-observer-new/viewport-observer/utils/get-mutated-elements.d.ts +6 -0
- package/dist/types-ts4.5/common/common/types.d.ts +1 -0
- package/dist/types-ts4.5/create-interaction-extra-metrics-payload/index.d.ts +1 -0
- package/dist/types-ts4.5/create-payload/index.d.ts +384 -0
- package/dist/types-ts4.5/interaction-metrics/index.d.ts +2 -2
- package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/get-mutated-elements.d.ts +6 -0
- package/package.json +1 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 4.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`092ad737a2396`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/092ad737a2396) -
|
|
8
|
+
handle nested display contents elements in TTVC v4
|
|
9
|
+
- [`63743e34fad29`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/63743e34fad29) -
|
|
10
|
+
Add an optional arg to func addError and addErrorToAll so that to error hash can be included in
|
|
11
|
+
UFO messages
|
|
12
|
+
|
|
3
13
|
## 4.10.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -588,7 +588,7 @@ var ModuleLoadingProfiler = exports.ModuleLoadingProfiler = {
|
|
|
588
588
|
removeHoldByID(currentInteractionId, id);
|
|
589
589
|
}
|
|
590
590
|
};
|
|
591
|
-
function addError(interactionId, name, labelStack, errorType, errorMessage, errorStack, forcedError) {
|
|
591
|
+
function addError(interactionId, name, labelStack, errorType, errorMessage, errorStack, forcedError, errorHash) {
|
|
592
592
|
var interaction = _constants.interactions.get(interactionId);
|
|
593
593
|
if (interaction != null) {
|
|
594
594
|
interaction.errors.push({
|
|
@@ -597,18 +597,20 @@ function addError(interactionId, name, labelStack, errorType, errorMessage, erro
|
|
|
597
597
|
errorType: errorType,
|
|
598
598
|
errorMessage: errorMessage,
|
|
599
599
|
errorStack: errorStack,
|
|
600
|
-
forcedError: forcedError
|
|
600
|
+
forcedError: forcedError,
|
|
601
|
+
errorHash: errorHash
|
|
601
602
|
});
|
|
602
603
|
}
|
|
603
604
|
}
|
|
604
|
-
function addErrorToAll(name, labelStack, errorType, errorMessage, errorStack) {
|
|
605
|
+
function addErrorToAll(name, labelStack, errorType, errorMessage, errorStack, errorHash) {
|
|
605
606
|
_constants.interactions.forEach(function (interaction) {
|
|
606
607
|
interaction.errors.push({
|
|
607
608
|
name: name,
|
|
608
609
|
labelStack: labelStack,
|
|
609
610
|
errorType: errorType,
|
|
610
611
|
errorMessage: errorMessage,
|
|
611
|
-
errorStack: errorStack
|
|
612
|
+
errorStack: errorStack,
|
|
613
|
+
errorHash: errorHash
|
|
612
614
|
});
|
|
613
615
|
});
|
|
614
616
|
}
|
|
@@ -21,6 +21,7 @@ var _mutationObserver = _interopRequireDefault(require("./mutation-observer"));
|
|
|
21
21
|
var _performanceObserver = _interopRequireDefault(require("./performance-observer"));
|
|
22
22
|
var _checkDisplayContent = _interopRequireDefault(require("./utils/check-display-content"));
|
|
23
23
|
var _checkWithinComponent2 = _interopRequireWildcard(require("./utils/check-within-component"));
|
|
24
|
+
var _getMutatedElements = require("./utils/get-mutated-elements");
|
|
24
25
|
var _isInVcIgnoreIfNoLayoutShiftMarker = _interopRequireDefault(require("./utils/is-in-vc-ignore-if-no-layout-shift-marker"));
|
|
25
26
|
var _trackDisplayContentOccurrence = _interopRequireDefault(require("./utils/track-display-content-occurrence"));
|
|
26
27
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -126,7 +127,7 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
126
127
|
_iterator = _createForOfIteratorHelper(addedNodes);
|
|
127
128
|
_context2.prev = 4;
|
|
128
129
|
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
129
|
-
var addedNodeRef, addedNode, ssrState, SSRStateEnum, _this$intersectionObs, _this$intersectionObs2, ssrPlaceholderHandler, _this$intersectionObs3, result, _this$intersectionObs4, sameDeletedNode, isInIgnoreLsMarker, _this$intersectionObs5, _this$intersectionObs6, _checkWithinComponent, isWithinThirdPartySegment, _this$intersectionObs7,
|
|
130
|
+
var addedNodeRef, addedNode, ssrState, SSRStateEnum, _this$intersectionObs, _this$intersectionObs2, ssrPlaceholderHandler, _this$intersectionObs3, result, _this$intersectionObs4, sameDeletedNode, isInIgnoreLsMarker, _this$intersectionObs5, _this$intersectionObs6, _checkWithinComponent, isWithinThirdPartySegment, _this$intersectionObs7, _iterator2, _step2, _step2$value, isDisplayContentsElementChildren, element, _this$intersectionObs8, _this$intersectionObs9, validTargets, _iterator3, _step3, _this$intersectionObs0, validTarget, _this$intersectionObs1;
|
|
130
131
|
return _regenerator.default.wrap(function _loop$(_context) {
|
|
131
132
|
while (1) switch (_context.prev = _context.next) {
|
|
132
133
|
case 0:
|
|
@@ -239,22 +240,20 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
239
240
|
return _context.abrupt("return", 0);
|
|
240
241
|
case 45:
|
|
241
242
|
if ((0, _platformFeatureFlags.fg)('platform_ufo_vcnext_v4_enabled')) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
243
|
+
_iterator2 = _createForOfIteratorHelper((0, _getMutatedElements.getMutatedElements)(addedNode));
|
|
244
|
+
try {
|
|
245
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
246
|
+
_step2$value = _step2.value, isDisplayContentsElementChildren = _step2$value.isDisplayContentsElementChildren, element = _step2$value.element;
|
|
247
|
+
if (isDisplayContentsElementChildren) {
|
|
248
|
+
(_this$intersectionObs8 = _this.intersectionObserver) === null || _this$intersectionObs8 === void 0 || _this$intersectionObs8.watchAndTag(element, 'mutation:display-contents-children-element');
|
|
249
|
+
} else {
|
|
250
|
+
(_this$intersectionObs9 = _this.intersectionObserver) === null || _this$intersectionObs9 === void 0 || _this$intersectionObs9.watchAndTag(element, createElementMutationsWatcher(removedNodeRects));
|
|
250
251
|
}
|
|
251
|
-
} catch (err) {
|
|
252
|
-
_iterator2.e(err);
|
|
253
|
-
} finally {
|
|
254
|
-
_iterator2.f();
|
|
255
252
|
}
|
|
256
|
-
}
|
|
257
|
-
|
|
253
|
+
} catch (err) {
|
|
254
|
+
_iterator2.e(err);
|
|
255
|
+
} finally {
|
|
256
|
+
_iterator2.f();
|
|
258
257
|
}
|
|
259
258
|
} else {
|
|
260
259
|
if ((0, _platformFeatureFlags.fg)('platform_ufo_display_content_resolution_ttvc_v3')) {
|
|
@@ -401,7 +400,6 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
401
400
|
}
|
|
402
401
|
};
|
|
403
402
|
});
|
|
404
|
-
// }
|
|
405
403
|
});
|
|
406
404
|
(0, _defineProperty2.default)(this, "handleLayoutShift", function (_ref8) {
|
|
407
405
|
var time = _ref8.time,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getMutatedElements = getMutatedElements;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
10
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
|
+
var MAX_NESTED_LEVELS_OF_DISPLAY_CONTENT_ELEMENTS_HANDLED = 3;
|
|
13
|
+
function getMutatedElements(element) {
|
|
14
|
+
var _window;
|
|
15
|
+
var depthLevel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
16
|
+
if (((_window = window) === null || _window === void 0 || (_window = _window.getComputedStyle(element)) === null || _window === void 0 ? void 0 : _window.display) === 'contents') {
|
|
17
|
+
var mutatedElements = [];
|
|
18
|
+
var nestedDisplayContentsElementChildren = [];
|
|
19
|
+
var _iterator = _createForOfIteratorHelper(element.children),
|
|
20
|
+
_step;
|
|
21
|
+
try {
|
|
22
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
23
|
+
var _window2;
|
|
24
|
+
var child = _step.value;
|
|
25
|
+
if (((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.getComputedStyle(child)) === null || _window2 === void 0 ? void 0 : _window2.display) === 'contents') {
|
|
26
|
+
nestedDisplayContentsElementChildren.push(child);
|
|
27
|
+
}
|
|
28
|
+
mutatedElements.push({
|
|
29
|
+
element: child,
|
|
30
|
+
isDisplayContentsElementChildren: true
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
} catch (err) {
|
|
34
|
+
_iterator.e(err);
|
|
35
|
+
} finally {
|
|
36
|
+
_iterator.f();
|
|
37
|
+
}
|
|
38
|
+
if (depthLevel < MAX_NESTED_LEVELS_OF_DISPLAY_CONTENT_ELEMENTS_HANDLED && nestedDisplayContentsElementChildren.length > 0) {
|
|
39
|
+
return [].concat(mutatedElements, (0, _toConsumableArray2.default)(nestedDisplayContentsElementChildren.map(function (element) {
|
|
40
|
+
return getMutatedElements(element, depthLevel + 1);
|
|
41
|
+
}).flat()));
|
|
42
|
+
}
|
|
43
|
+
return mutatedElements;
|
|
44
|
+
} else {
|
|
45
|
+
return [{
|
|
46
|
+
element: element,
|
|
47
|
+
isDisplayContentsElementChildren: false
|
|
48
|
+
}];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -507,7 +507,7 @@ export const ModuleLoadingProfiler = {
|
|
|
507
507
|
removeHoldByID(currentInteractionId, id);
|
|
508
508
|
}
|
|
509
509
|
};
|
|
510
|
-
export function addError(interactionId, name, labelStack, errorType, errorMessage, errorStack, forcedError) {
|
|
510
|
+
export function addError(interactionId, name, labelStack, errorType, errorMessage, errorStack, forcedError, errorHash) {
|
|
511
511
|
const interaction = interactions.get(interactionId);
|
|
512
512
|
if (interaction != null) {
|
|
513
513
|
interaction.errors.push({
|
|
@@ -516,18 +516,20 @@ export function addError(interactionId, name, labelStack, errorType, errorMessag
|
|
|
516
516
|
errorType,
|
|
517
517
|
errorMessage,
|
|
518
518
|
errorStack,
|
|
519
|
-
forcedError
|
|
519
|
+
forcedError,
|
|
520
|
+
errorHash
|
|
520
521
|
});
|
|
521
522
|
}
|
|
522
523
|
}
|
|
523
|
-
export function addErrorToAll(name, labelStack, errorType, errorMessage, errorStack) {
|
|
524
|
+
export function addErrorToAll(name, labelStack, errorType, errorMessage, errorStack, errorHash) {
|
|
524
525
|
interactions.forEach(interaction => {
|
|
525
526
|
interaction.errors.push({
|
|
526
527
|
name,
|
|
527
528
|
labelStack,
|
|
528
529
|
errorType,
|
|
529
530
|
errorMessage,
|
|
530
|
-
errorStack
|
|
531
|
+
errorStack,
|
|
532
|
+
errorHash
|
|
531
533
|
});
|
|
532
534
|
});
|
|
533
535
|
}
|
|
@@ -9,6 +9,7 @@ import createMutationObserver from './mutation-observer';
|
|
|
9
9
|
import createPerformanceObserver from './performance-observer';
|
|
10
10
|
import checkCssProperty from './utils/check-display-content';
|
|
11
11
|
import checkWithinComponent, { cleanupCaches } from './utils/check-within-component';
|
|
12
|
+
import { getMutatedElements } from './utils/get-mutated-elements';
|
|
12
13
|
import isInVCIgnoreIfNoLayoutShiftMarker from './utils/is-in-vc-ignore-if-no-layout-shift-marker';
|
|
13
14
|
import trackDisplayContentsOccurrence from './utils/track-display-content-occurrence';
|
|
14
15
|
function isElementVisible(element) {
|
|
@@ -188,17 +189,17 @@ export default class ViewportObserver {
|
|
|
188
189
|
continue;
|
|
189
190
|
}
|
|
190
191
|
if (fg('platform_ufo_vcnext_v4_enabled')) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
192
|
+
for (const {
|
|
193
|
+
isDisplayContentsElementChildren,
|
|
194
|
+
element
|
|
195
|
+
} of getMutatedElements(addedNode)) {
|
|
196
|
+
if (isDisplayContentsElementChildren) {
|
|
197
|
+
var _this$intersectionObs8;
|
|
198
|
+
(_this$intersectionObs8 = this.intersectionObserver) === null || _this$intersectionObs8 === void 0 ? void 0 : _this$intersectionObs8.watchAndTag(element, 'mutation:display-contents-children-element');
|
|
199
|
+
} else {
|
|
200
|
+
var _this$intersectionObs9;
|
|
201
|
+
(_this$intersectionObs9 = this.intersectionObserver) === null || _this$intersectionObs9 === void 0 ? void 0 : _this$intersectionObs9.watchAndTag(element, createElementMutationsWatcher(removedNodeRects));
|
|
198
202
|
}
|
|
199
|
-
} else {
|
|
200
|
-
var _this$intersectionObs9;
|
|
201
|
-
(_this$intersectionObs9 = this.intersectionObserver) === null || _this$intersectionObs9 === void 0 ? void 0 : _this$intersectionObs9.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
|
|
202
203
|
}
|
|
203
204
|
} else {
|
|
204
205
|
if (fg('platform_ufo_display_content_resolution_ttvc_v3')) {
|
|
@@ -299,7 +300,6 @@ export default class ViewportObserver {
|
|
|
299
300
|
}
|
|
300
301
|
};
|
|
301
302
|
});
|
|
302
|
-
// }
|
|
303
303
|
});
|
|
304
304
|
_defineProperty(this, "handleLayoutShift", ({
|
|
305
305
|
time,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const MAX_NESTED_LEVELS_OF_DISPLAY_CONTENT_ELEMENTS_HANDLED = 3;
|
|
2
|
+
export function getMutatedElements(element, depthLevel = 0) {
|
|
3
|
+
var _window, _window$getComputedSt;
|
|
4
|
+
if (((_window = window) === null || _window === void 0 ? void 0 : (_window$getComputedSt = _window.getComputedStyle(element)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.display) === 'contents') {
|
|
5
|
+
const mutatedElements = [];
|
|
6
|
+
const nestedDisplayContentsElementChildren = [];
|
|
7
|
+
for (const child of element.children) {
|
|
8
|
+
var _window2, _window2$getComputedS;
|
|
9
|
+
if (((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$getComputedS = _window2.getComputedStyle(child)) === null || _window2$getComputedS === void 0 ? void 0 : _window2$getComputedS.display) === 'contents') {
|
|
10
|
+
nestedDisplayContentsElementChildren.push(child);
|
|
11
|
+
}
|
|
12
|
+
mutatedElements.push({
|
|
13
|
+
element: child,
|
|
14
|
+
isDisplayContentsElementChildren: true
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (depthLevel < MAX_NESTED_LEVELS_OF_DISPLAY_CONTENT_ELEMENTS_HANDLED && nestedDisplayContentsElementChildren.length > 0) {
|
|
18
|
+
return [...mutatedElements, ...nestedDisplayContentsElementChildren.map(element => getMutatedElements(element, depthLevel + 1)).flat()];
|
|
19
|
+
}
|
|
20
|
+
return mutatedElements;
|
|
21
|
+
} else {
|
|
22
|
+
return [{
|
|
23
|
+
element,
|
|
24
|
+
isDisplayContentsElementChildren: false
|
|
25
|
+
}];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -542,7 +542,7 @@ export var ModuleLoadingProfiler = {
|
|
|
542
542
|
removeHoldByID(currentInteractionId, id);
|
|
543
543
|
}
|
|
544
544
|
};
|
|
545
|
-
export function addError(interactionId, name, labelStack, errorType, errorMessage, errorStack, forcedError) {
|
|
545
|
+
export function addError(interactionId, name, labelStack, errorType, errorMessage, errorStack, forcedError, errorHash) {
|
|
546
546
|
var interaction = interactions.get(interactionId);
|
|
547
547
|
if (interaction != null) {
|
|
548
548
|
interaction.errors.push({
|
|
@@ -551,18 +551,20 @@ export function addError(interactionId, name, labelStack, errorType, errorMessag
|
|
|
551
551
|
errorType: errorType,
|
|
552
552
|
errorMessage: errorMessage,
|
|
553
553
|
errorStack: errorStack,
|
|
554
|
-
forcedError: forcedError
|
|
554
|
+
forcedError: forcedError,
|
|
555
|
+
errorHash: errorHash
|
|
555
556
|
});
|
|
556
557
|
}
|
|
557
558
|
}
|
|
558
|
-
export function addErrorToAll(name, labelStack, errorType, errorMessage, errorStack) {
|
|
559
|
+
export function addErrorToAll(name, labelStack, errorType, errorMessage, errorStack, errorHash) {
|
|
559
560
|
interactions.forEach(function (interaction) {
|
|
560
561
|
interaction.errors.push({
|
|
561
562
|
name: name,
|
|
562
563
|
labelStack: labelStack,
|
|
563
564
|
errorType: errorType,
|
|
564
565
|
errorMessage: errorMessage,
|
|
565
|
-
errorStack: errorStack
|
|
566
|
+
errorStack: errorStack,
|
|
567
|
+
errorHash: errorHash
|
|
566
568
|
});
|
|
567
569
|
});
|
|
568
570
|
}
|
|
@@ -16,6 +16,7 @@ import createMutationObserver from './mutation-observer';
|
|
|
16
16
|
import createPerformanceObserver from './performance-observer';
|
|
17
17
|
import checkCssProperty from './utils/check-display-content';
|
|
18
18
|
import checkWithinComponent, { cleanupCaches } from './utils/check-within-component';
|
|
19
|
+
import { getMutatedElements } from './utils/get-mutated-elements';
|
|
19
20
|
import isInVCIgnoreIfNoLayoutShiftMarker from './utils/is-in-vc-ignore-if-no-layout-shift-marker';
|
|
20
21
|
import trackDisplayContentsOccurrence from './utils/track-display-content-occurrence';
|
|
21
22
|
function isElementVisible(element) {
|
|
@@ -117,7 +118,7 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
117
118
|
_iterator = _createForOfIteratorHelper(addedNodes);
|
|
118
119
|
_context2.prev = 4;
|
|
119
120
|
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
|
|
120
|
-
var addedNodeRef, addedNode, ssrState, SSRStateEnum, _this$intersectionObs, _this$intersectionObs2, ssrPlaceholderHandler, _this$intersectionObs3, result, _this$intersectionObs4, sameDeletedNode, isInIgnoreLsMarker, _this$intersectionObs5, _this$intersectionObs6, _checkWithinComponent, isWithinThirdPartySegment, _this$intersectionObs7,
|
|
121
|
+
var addedNodeRef, addedNode, ssrState, SSRStateEnum, _this$intersectionObs, _this$intersectionObs2, ssrPlaceholderHandler, _this$intersectionObs3, result, _this$intersectionObs4, sameDeletedNode, isInIgnoreLsMarker, _this$intersectionObs5, _this$intersectionObs6, _checkWithinComponent, isWithinThirdPartySegment, _this$intersectionObs7, _iterator2, _step2, _step2$value, isDisplayContentsElementChildren, element, _this$intersectionObs8, _this$intersectionObs9, validTargets, _iterator3, _step3, _this$intersectionObs0, validTarget, _this$intersectionObs1;
|
|
121
122
|
return _regeneratorRuntime.wrap(function _loop$(_context) {
|
|
122
123
|
while (1) switch (_context.prev = _context.next) {
|
|
123
124
|
case 0:
|
|
@@ -230,22 +231,20 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
230
231
|
return _context.abrupt("return", 0);
|
|
231
232
|
case 45:
|
|
232
233
|
if (fg('platform_ufo_vcnext_v4_enabled')) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
234
|
+
_iterator2 = _createForOfIteratorHelper(getMutatedElements(addedNode));
|
|
235
|
+
try {
|
|
236
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
237
|
+
_step2$value = _step2.value, isDisplayContentsElementChildren = _step2$value.isDisplayContentsElementChildren, element = _step2$value.element;
|
|
238
|
+
if (isDisplayContentsElementChildren) {
|
|
239
|
+
(_this$intersectionObs8 = _this.intersectionObserver) === null || _this$intersectionObs8 === void 0 || _this$intersectionObs8.watchAndTag(element, 'mutation:display-contents-children-element');
|
|
240
|
+
} else {
|
|
241
|
+
(_this$intersectionObs9 = _this.intersectionObserver) === null || _this$intersectionObs9 === void 0 || _this$intersectionObs9.watchAndTag(element, createElementMutationsWatcher(removedNodeRects));
|
|
241
242
|
}
|
|
242
|
-
} catch (err) {
|
|
243
|
-
_iterator2.e(err);
|
|
244
|
-
} finally {
|
|
245
|
-
_iterator2.f();
|
|
246
243
|
}
|
|
247
|
-
}
|
|
248
|
-
|
|
244
|
+
} catch (err) {
|
|
245
|
+
_iterator2.e(err);
|
|
246
|
+
} finally {
|
|
247
|
+
_iterator2.f();
|
|
249
248
|
}
|
|
250
249
|
} else {
|
|
251
250
|
if (fg('platform_ufo_display_content_resolution_ttvc_v3')) {
|
|
@@ -392,7 +391,6 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
392
391
|
}
|
|
393
392
|
};
|
|
394
393
|
});
|
|
395
|
-
// }
|
|
396
394
|
});
|
|
397
395
|
_defineProperty(this, "handleLayoutShift", function (_ref8) {
|
|
398
396
|
var time = _ref8.time,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
var MAX_NESTED_LEVELS_OF_DISPLAY_CONTENT_ELEMENTS_HANDLED = 3;
|
|
6
|
+
export function getMutatedElements(element) {
|
|
7
|
+
var _window;
|
|
8
|
+
var depthLevel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
9
|
+
if (((_window = window) === null || _window === void 0 || (_window = _window.getComputedStyle(element)) === null || _window === void 0 ? void 0 : _window.display) === 'contents') {
|
|
10
|
+
var mutatedElements = [];
|
|
11
|
+
var nestedDisplayContentsElementChildren = [];
|
|
12
|
+
var _iterator = _createForOfIteratorHelper(element.children),
|
|
13
|
+
_step;
|
|
14
|
+
try {
|
|
15
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
16
|
+
var _window2;
|
|
17
|
+
var child = _step.value;
|
|
18
|
+
if (((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.getComputedStyle(child)) === null || _window2 === void 0 ? void 0 : _window2.display) === 'contents') {
|
|
19
|
+
nestedDisplayContentsElementChildren.push(child);
|
|
20
|
+
}
|
|
21
|
+
mutatedElements.push({
|
|
22
|
+
element: child,
|
|
23
|
+
isDisplayContentsElementChildren: true
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
} catch (err) {
|
|
27
|
+
_iterator.e(err);
|
|
28
|
+
} finally {
|
|
29
|
+
_iterator.f();
|
|
30
|
+
}
|
|
31
|
+
if (depthLevel < MAX_NESTED_LEVELS_OF_DISPLAY_CONTENT_ELEMENTS_HANDLED && nestedDisplayContentsElementChildren.length > 0) {
|
|
32
|
+
return [].concat(mutatedElements, _toConsumableArray(nestedDisplayContentsElementChildren.map(function (element) {
|
|
33
|
+
return getMutatedElements(element, depthLevel + 1);
|
|
34
|
+
}).flat()));
|
|
35
|
+
}
|
|
36
|
+
return mutatedElements;
|
|
37
|
+
} else {
|
|
38
|
+
return [{
|
|
39
|
+
element: element,
|
|
40
|
+
isDisplayContentsElementChildren: false
|
|
41
|
+
}];
|
|
42
|
+
}
|
|
43
|
+
}
|