@atlaskit/react-ufo 4.5.1 → 4.5.3

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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 4.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5c1bb03531687`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5c1bb03531687) -
8
+ FG cleanup - platform_ufo_handle_non_react_element_for_3p
9
+
10
+ ## 4.5.2
11
+
12
+ ### Patch Changes
13
+
14
+ - [`4dc561b657a31`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4dc561b657a31) -
15
+ FG cleanup - platform_ufo_report_non_htmlelement_selectors
16
+ - [`0251aa356dcf9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0251aa356dcf9) -
17
+ fix logic on checkIfExistedAndSizeMatchingV3 function
18
+
3
19
  ## 4.5.1
4
20
 
5
21
  ### Patch Changes
@@ -239,7 +239,11 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
239
239
  value: function checkIfExistedAndSizeMatchingV3(el) {
240
240
  el = this.findNearestPlaceholderContainerIfIgnored(el);
241
241
  var id = this.getPlaceholderId(el);
242
- return this.staticPlaceholders.has(id);
242
+ var placeholderRects = this.staticPlaceholders.get(id);
243
+ if (!placeholderRects) {
244
+ return false;
245
+ }
246
+ return this.hasSameSizePosition(placeholderRects, el.getBoundingClientRect());
243
247
  }
244
248
  }, {
245
249
  key: "getSize",
@@ -4,37 +4,32 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
7
  var nameCache = new WeakMap();
9
8
  function getElementName(selectorConfig, element) {
10
9
  if (!(element instanceof HTMLElement)) {
11
- if ((0, _platformFeatureFlags.fg)('platform_ufo_report_non_htmlelement_selectors')) {
12
- var elementInstance = 'Unknown';
10
+ var elementInstance = 'Unknown';
13
11
 
14
- // Types of elements according to LLM
15
- if (element instanceof Document) {
16
- elementInstance = 'Document';
17
- } else if (element instanceof DocumentFragment) {
18
- elementInstance = 'DocumentFragment';
19
- } else if (element instanceof Text) {
20
- elementInstance = 'Text';
21
- } else if (element instanceof Comment) {
22
- elementInstance = 'Comment';
23
- } else if (element instanceof ProcessingInstruction) {
24
- elementInstance = 'ProcessingInstruction';
25
- } else if (element instanceof Attr) {
26
- elementInstance = 'Attr';
27
- } else if (element instanceof CDATASection) {
28
- elementInstance = 'CDATASection';
29
- }
30
- if (element.parentElement && element.parentElement instanceof HTMLElement) {
31
- var parentElementSelector = getElementName(selectorConfig, element.parentElement);
32
- return "".concat(parentElementSelector, " > ").concat(elementInstance);
33
- } else {
34
- return elementInstance;
35
- }
12
+ // Types of elements according to LLM
13
+ if (element instanceof Text) {
14
+ elementInstance = 'Text';
15
+ } else if (element instanceof DocumentFragment) {
16
+ elementInstance = 'DocumentFragment';
17
+ } else if (element instanceof Document) {
18
+ elementInstance = 'Document';
19
+ } else if (element instanceof Comment) {
20
+ elementInstance = 'Comment';
21
+ } else if (element instanceof ProcessingInstruction) {
22
+ elementInstance = 'ProcessingInstruction';
23
+ } else if (element instanceof Attr) {
24
+ elementInstance = 'Attr';
25
+ } else if (element instanceof CDATASection) {
26
+ elementInstance = 'CDATASection';
27
+ }
28
+ if (element.parentElement && element.parentElement instanceof HTMLElement) {
29
+ var parentElementSelector = getElementName(selectorConfig, element.parentElement);
30
+ return "".concat(parentElementSelector, " > ").concat(elementInstance);
36
31
  } else {
37
- return 'error';
32
+ return elementInstance;
38
33
  }
39
34
  }
40
35
  var cachedName = nameCache.get(element);
@@ -6,11 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.cleanupCaches = cleanupCaches;
8
8
  exports.default = checkWithinComponent;
9
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
9
  var _coinflip = _interopRequireDefault(require("../../../../coinflip"));
11
10
  var _checkFiberWithinComponent = _interopRequireDefault(require("./check-fiber-within-component"));
12
11
  var _findFiberWithCache = _interopRequireDefault(require("./find-fiber-with-cache"));
13
- var _findReactFiber = _interopRequireDefault(require("./find-react-fiber"));
14
12
  var DEFAULT_MAX_LEVEL = 20;
15
13
 
16
14
  // Cache cleanup
@@ -37,27 +35,21 @@ function checkWithinComponent(node, targetComponentName, resultCache) {
37
35
  }
38
36
  var fiber = null;
39
37
  var checkedNodes = [];
40
- if ((0, _platformFeatureFlags.fg)('platform_ufo_handle_non_react_element_for_3p')) {
41
- fiber = (0, _findFiberWithCache.default)(node, DEFAULT_MAX_LEVEL, checkedNodes);
42
- } else {
43
- fiber = (0, _findReactFiber.default)(node);
44
- }
38
+
39
+ // Always use cached fiber strategy to handle non-React elements reliably
40
+ fiber = (0, _findFiberWithCache.default)(node, DEFAULT_MAX_LEVEL, checkedNodes);
45
41
  if (!fiber) {
46
- if ((0, _platformFeatureFlags.fg)('platform_ufo_handle_non_react_element_for_3p')) {
47
- checkedNodes.forEach(function (checkedNode) {
48
- resultCache.set(checkedNode, false);
49
- });
50
- }
42
+ checkedNodes.forEach(function (checkedNode) {
43
+ resultCache.set(checkedNode, false);
44
+ });
51
45
  return {
52
46
  isWithin: false
53
47
  };
54
48
  }
55
49
  var isWithin = (0, _checkFiberWithinComponent.default)(fiber, targetComponentName, DEFAULT_MAX_LEVEL);
56
- if ((0, _platformFeatureFlags.fg)('platform_ufo_handle_non_react_element_for_3p')) {
57
- checkedNodes.forEach(function (checkedNode) {
58
- resultCache.set(checkedNode, isWithin);
59
- });
60
- }
50
+ checkedNodes.forEach(function (checkedNode) {
51
+ resultCache.set(checkedNode, isWithin);
52
+ });
61
53
  return {
62
54
  isWithin: isWithin
63
55
  };
@@ -205,7 +205,11 @@ export class SSRPlaceholderHandlers {
205
205
  checkIfExistedAndSizeMatchingV3(el) {
206
206
  el = this.findNearestPlaceholderContainerIfIgnored(el);
207
207
  const id = this.getPlaceholderId(el);
208
- return this.staticPlaceholders.has(id);
208
+ const placeholderRects = this.staticPlaceholders.get(id);
209
+ if (!placeholderRects) {
210
+ return false;
211
+ }
212
+ return this.hasSameSizePosition(placeholderRects, el.getBoundingClientRect());
209
213
  }
210
214
  getSize(el) {
211
215
  return new Promise(resolve => {
@@ -1,34 +1,29 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
2
1
  const nameCache = new WeakMap();
3
2
  function getElementName(selectorConfig, element) {
4
3
  if (!(element instanceof HTMLElement)) {
5
- if (fg('platform_ufo_report_non_htmlelement_selectors')) {
6
- let elementInstance = 'Unknown';
4
+ let elementInstance = 'Unknown';
7
5
 
8
- // Types of elements according to LLM
9
- if (element instanceof Document) {
10
- elementInstance = 'Document';
11
- } else if (element instanceof DocumentFragment) {
12
- elementInstance = 'DocumentFragment';
13
- } else if (element instanceof Text) {
14
- elementInstance = 'Text';
15
- } else if (element instanceof Comment) {
16
- elementInstance = 'Comment';
17
- } else if (element instanceof ProcessingInstruction) {
18
- elementInstance = 'ProcessingInstruction';
19
- } else if (element instanceof Attr) {
20
- elementInstance = 'Attr';
21
- } else if (element instanceof CDATASection) {
22
- elementInstance = 'CDATASection';
23
- }
24
- if (element.parentElement && element.parentElement instanceof HTMLElement) {
25
- const parentElementSelector = getElementName(selectorConfig, element.parentElement);
26
- return `${parentElementSelector} > ${elementInstance}`;
27
- } else {
28
- return elementInstance;
29
- }
6
+ // Types of elements according to LLM
7
+ if (element instanceof Text) {
8
+ elementInstance = 'Text';
9
+ } else if (element instanceof DocumentFragment) {
10
+ elementInstance = 'DocumentFragment';
11
+ } else if (element instanceof Document) {
12
+ elementInstance = 'Document';
13
+ } else if (element instanceof Comment) {
14
+ elementInstance = 'Comment';
15
+ } else if (element instanceof ProcessingInstruction) {
16
+ elementInstance = 'ProcessingInstruction';
17
+ } else if (element instanceof Attr) {
18
+ elementInstance = 'Attr';
19
+ } else if (element instanceof CDATASection) {
20
+ elementInstance = 'CDATASection';
21
+ }
22
+ if (element.parentElement && element.parentElement instanceof HTMLElement) {
23
+ const parentElementSelector = getElementName(selectorConfig, element.parentElement);
24
+ return `${parentElementSelector} > ${elementInstance}`;
30
25
  } else {
31
- return 'error';
26
+ return elementInstance;
32
27
  }
33
28
  }
34
29
  const cachedName = nameCache.get(element);
@@ -1,8 +1,6 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
2
1
  import coinflip from '../../../../coinflip';
3
2
  import checkFiberWithinComponent from './check-fiber-within-component';
4
3
  import findFiberWithCache from './find-fiber-with-cache';
5
- import findReactFiber from './find-react-fiber';
6
4
  const DEFAULT_MAX_LEVEL = 20;
7
5
 
8
6
  // Cache cleanup
@@ -29,27 +27,21 @@ export default function checkWithinComponent(node, targetComponentName, resultCa
29
27
  }
30
28
  let fiber = null;
31
29
  let checkedNodes = [];
32
- if (fg('platform_ufo_handle_non_react_element_for_3p')) {
33
- fiber = findFiberWithCache(node, DEFAULT_MAX_LEVEL, checkedNodes);
34
- } else {
35
- fiber = findReactFiber(node);
36
- }
30
+
31
+ // Always use cached fiber strategy to handle non-React elements reliably
32
+ fiber = findFiberWithCache(node, DEFAULT_MAX_LEVEL, checkedNodes);
37
33
  if (!fiber) {
38
- if (fg('platform_ufo_handle_non_react_element_for_3p')) {
39
- checkedNodes.forEach(checkedNode => {
40
- resultCache.set(checkedNode, false);
41
- });
42
- }
34
+ checkedNodes.forEach(checkedNode => {
35
+ resultCache.set(checkedNode, false);
36
+ });
43
37
  return {
44
38
  isWithin: false
45
39
  };
46
40
  }
47
41
  const isWithin = checkFiberWithinComponent(fiber, targetComponentName, DEFAULT_MAX_LEVEL);
48
- if (fg('platform_ufo_handle_non_react_element_for_3p')) {
49
- checkedNodes.forEach(checkedNode => {
50
- resultCache.set(checkedNode, isWithin);
51
- });
52
- }
42
+ checkedNodes.forEach(checkedNode => {
43
+ resultCache.set(checkedNode, isWithin);
44
+ });
53
45
  return {
54
46
  isWithin
55
47
  };
@@ -232,7 +232,11 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
232
232
  value: function checkIfExistedAndSizeMatchingV3(el) {
233
233
  el = this.findNearestPlaceholderContainerIfIgnored(el);
234
234
  var id = this.getPlaceholderId(el);
235
- return this.staticPlaceholders.has(id);
235
+ var placeholderRects = this.staticPlaceholders.get(id);
236
+ if (!placeholderRects) {
237
+ return false;
238
+ }
239
+ return this.hasSameSizePosition(placeholderRects, el.getBoundingClientRect());
236
240
  }
237
241
  }, {
238
242
  key: "getSize",
@@ -1,34 +1,29 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
2
1
  var nameCache = new WeakMap();
3
2
  function getElementName(selectorConfig, element) {
4
3
  if (!(element instanceof HTMLElement)) {
5
- if (fg('platform_ufo_report_non_htmlelement_selectors')) {
6
- var elementInstance = 'Unknown';
4
+ var elementInstance = 'Unknown';
7
5
 
8
- // Types of elements according to LLM
9
- if (element instanceof Document) {
10
- elementInstance = 'Document';
11
- } else if (element instanceof DocumentFragment) {
12
- elementInstance = 'DocumentFragment';
13
- } else if (element instanceof Text) {
14
- elementInstance = 'Text';
15
- } else if (element instanceof Comment) {
16
- elementInstance = 'Comment';
17
- } else if (element instanceof ProcessingInstruction) {
18
- elementInstance = 'ProcessingInstruction';
19
- } else if (element instanceof Attr) {
20
- elementInstance = 'Attr';
21
- } else if (element instanceof CDATASection) {
22
- elementInstance = 'CDATASection';
23
- }
24
- if (element.parentElement && element.parentElement instanceof HTMLElement) {
25
- var parentElementSelector = getElementName(selectorConfig, element.parentElement);
26
- return "".concat(parentElementSelector, " > ").concat(elementInstance);
27
- } else {
28
- return elementInstance;
29
- }
6
+ // Types of elements according to LLM
7
+ if (element instanceof Text) {
8
+ elementInstance = 'Text';
9
+ } else if (element instanceof DocumentFragment) {
10
+ elementInstance = 'DocumentFragment';
11
+ } else if (element instanceof Document) {
12
+ elementInstance = 'Document';
13
+ } else if (element instanceof Comment) {
14
+ elementInstance = 'Comment';
15
+ } else if (element instanceof ProcessingInstruction) {
16
+ elementInstance = 'ProcessingInstruction';
17
+ } else if (element instanceof Attr) {
18
+ elementInstance = 'Attr';
19
+ } else if (element instanceof CDATASection) {
20
+ elementInstance = 'CDATASection';
21
+ }
22
+ if (element.parentElement && element.parentElement instanceof HTMLElement) {
23
+ var parentElementSelector = getElementName(selectorConfig, element.parentElement);
24
+ return "".concat(parentElementSelector, " > ").concat(elementInstance);
30
25
  } else {
31
- return 'error';
26
+ return elementInstance;
32
27
  }
33
28
  }
34
29
  var cachedName = nameCache.get(element);
@@ -1,8 +1,6 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
2
1
  import coinflip from '../../../../coinflip';
3
2
  import checkFiberWithinComponent from './check-fiber-within-component';
4
3
  import findFiberWithCache from './find-fiber-with-cache';
5
- import findReactFiber from './find-react-fiber';
6
4
  var DEFAULT_MAX_LEVEL = 20;
7
5
 
8
6
  // Cache cleanup
@@ -29,27 +27,21 @@ export default function checkWithinComponent(node, targetComponentName, resultCa
29
27
  }
30
28
  var fiber = null;
31
29
  var checkedNodes = [];
32
- if (fg('platform_ufo_handle_non_react_element_for_3p')) {
33
- fiber = findFiberWithCache(node, DEFAULT_MAX_LEVEL, checkedNodes);
34
- } else {
35
- fiber = findReactFiber(node);
36
- }
30
+
31
+ // Always use cached fiber strategy to handle non-React elements reliably
32
+ fiber = findFiberWithCache(node, DEFAULT_MAX_LEVEL, checkedNodes);
37
33
  if (!fiber) {
38
- if (fg('platform_ufo_handle_non_react_element_for_3p')) {
39
- checkedNodes.forEach(function (checkedNode) {
40
- resultCache.set(checkedNode, false);
41
- });
42
- }
34
+ checkedNodes.forEach(function (checkedNode) {
35
+ resultCache.set(checkedNode, false);
36
+ });
43
37
  return {
44
38
  isWithin: false
45
39
  };
46
40
  }
47
41
  var isWithin = checkFiberWithinComponent(fiber, targetComponentName, DEFAULT_MAX_LEVEL);
48
- if (fg('platform_ufo_handle_non_react_element_for_3p')) {
49
- checkedNodes.forEach(function (checkedNode) {
50
- resultCache.set(checkedNode, isWithin);
51
- });
52
- }
42
+ checkedNodes.forEach(function (checkedNode) {
43
+ resultCache.set(checkedNode, isWithin);
44
+ });
53
45
  return {
54
46
  isWithin: isWithin
55
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "4.5.1",
3
+ "version": "4.5.3",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -175,15 +175,9 @@
175
175
  "platform_ufo_enable_vc_press_interactions": {
176
176
  "type": "boolean"
177
177
  },
178
- "platform_ufo_handle_non_react_element_for_3p": {
179
- "type": "boolean"
180
- },
181
178
  "platform_ufo_segment_critical_metrics": {
182
179
  "type": "boolean"
183
180
  },
184
- "platform_ufo_report_non_htmlelement_selectors": {
185
- "type": "boolean"
186
- },
187
181
  "platform_ufo_add_segments_count_threshold": {
188
182
  "type": "boolean"
189
183
  },