@atlaskit/react-ufo 4.15.10 → 4.15.12

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.
@@ -242,6 +242,28 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
242
242
  }
243
243
  return element;
244
244
  }
245
+ }, {
246
+ key: "findNearestPlaceholderOrContainer",
247
+ value: function findNearestPlaceholderOrContainer(element) {
248
+ var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ANCESTOR_LOOKUP_LIMIT;
249
+ var ancestor = element;
250
+ if (this.isPlaceholderIgnored(element) && element.parentElement) {
251
+ ancestor = element.parentElement;
252
+ }
253
+ var i = 0;
254
+ while (ancestor && i < limit) {
255
+ if (this.isPlaceholder(ancestor) || this.isPlaceholderReplacement(ancestor)) {
256
+ return ancestor;
257
+ }
258
+ if (ancestor.parentElement) {
259
+ ancestor = ancestor.parentElement;
260
+ i++;
261
+ } else {
262
+ break;
263
+ }
264
+ }
265
+ return element;
266
+ }
245
267
 
246
268
  // Validates placeholder match using asynchronous observation and resolves with the result
247
269
  }, {
@@ -304,7 +326,8 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
304
326
  }, {
305
327
  key: "validateReactComponentMatchToPlaceholderV4",
306
328
  value: function validateReactComponentMatchToPlaceholderV4(el) {
307
- el = this.findNearestPlaceholderContainerIfIgnored(el);
329
+ el = (0, _platformFeatureFlags.fg)('platform_ufo_v4_fix_nested_ssr_placeholder') ? this.findNearestPlaceholderOrContainer(el, 2) // We are using 2 due to over-eagerness of the default, only check itself and 1 ancestor
330
+ : this.findNearestPlaceholderContainerIfIgnored(el);
308
331
  var id = this.getPlaceholderReplacementId(el);
309
332
  return this.staticPlaceholders.has(id);
310
333
  }
@@ -209,6 +209,25 @@ export class SSRPlaceholderHandlers {
209
209
  }
210
210
  return element;
211
211
  }
212
+ findNearestPlaceholderOrContainer(element, limit = ANCESTOR_LOOKUP_LIMIT) {
213
+ let ancestor = element;
214
+ if (this.isPlaceholderIgnored(element) && element.parentElement) {
215
+ ancestor = element.parentElement;
216
+ }
217
+ let i = 0;
218
+ while (ancestor && i < limit) {
219
+ if (this.isPlaceholder(ancestor) || this.isPlaceholderReplacement(ancestor)) {
220
+ return ancestor;
221
+ }
222
+ if (ancestor.parentElement) {
223
+ ancestor = ancestor.parentElement;
224
+ i++;
225
+ } else {
226
+ break;
227
+ }
228
+ }
229
+ return element;
230
+ }
212
231
 
213
232
  // Validates placeholder match using asynchronous observation and resolves with the result
214
233
  checkIfExistedAndSizeMatching(el) {
@@ -258,7 +277,8 @@ export class SSRPlaceholderHandlers {
258
277
  });
259
278
  }
260
279
  validateReactComponentMatchToPlaceholderV4(el) {
261
- el = this.findNearestPlaceholderContainerIfIgnored(el);
280
+ el = fg('platform_ufo_v4_fix_nested_ssr_placeholder') ? this.findNearestPlaceholderOrContainer(el, 2) // We are using 2 due to over-eagerness of the default, only check itself and 1 ancestor
281
+ : this.findNearestPlaceholderContainerIfIgnored(el);
262
282
  const id = this.getPlaceholderReplacementId(el);
263
283
  return this.staticPlaceholders.has(id);
264
284
  }
@@ -235,6 +235,28 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
235
235
  }
236
236
  return element;
237
237
  }
238
+ }, {
239
+ key: "findNearestPlaceholderOrContainer",
240
+ value: function findNearestPlaceholderOrContainer(element) {
241
+ var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ANCESTOR_LOOKUP_LIMIT;
242
+ var ancestor = element;
243
+ if (this.isPlaceholderIgnored(element) && element.parentElement) {
244
+ ancestor = element.parentElement;
245
+ }
246
+ var i = 0;
247
+ while (ancestor && i < limit) {
248
+ if (this.isPlaceholder(ancestor) || this.isPlaceholderReplacement(ancestor)) {
249
+ return ancestor;
250
+ }
251
+ if (ancestor.parentElement) {
252
+ ancestor = ancestor.parentElement;
253
+ i++;
254
+ } else {
255
+ break;
256
+ }
257
+ }
258
+ return element;
259
+ }
238
260
 
239
261
  // Validates placeholder match using asynchronous observation and resolves with the result
240
262
  }, {
@@ -297,7 +319,8 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
297
319
  }, {
298
320
  key: "validateReactComponentMatchToPlaceholderV4",
299
321
  value: function validateReactComponentMatchToPlaceholderV4(el) {
300
- el = this.findNearestPlaceholderContainerIfIgnored(el);
322
+ el = fg('platform_ufo_v4_fix_nested_ssr_placeholder') ? this.findNearestPlaceholderOrContainer(el, 2) // We are using 2 due to over-eagerness of the default, only check itself and 1 ancestor
323
+ : this.findNearestPlaceholderContainerIfIgnored(el);
301
324
  var id = this.getPlaceholderReplacementId(el);
302
325
  return this.staticPlaceholders.has(id);
303
326
  }
@@ -31,6 +31,7 @@ export declare class SSRPlaceholderHandlers {
31
31
  isPlaceholderV4(element: HTMLElement): boolean;
32
32
  isPlaceholderReplacementV4(element: HTMLElement): boolean;
33
33
  findNearestPlaceholderContainerIfIgnored(element: HTMLElement): HTMLElement;
34
+ findNearestPlaceholderOrContainer(element: HTMLElement, limit?: number): HTMLElement;
34
35
  checkIfExistedAndSizeMatching(el: HTMLElement): Promise<boolean>;
35
36
  checkIfExistedAndSizeMatchingV3(el: HTMLElement): boolean;
36
37
  getSize(el: HTMLElement): Promise<Rect>;
@@ -31,6 +31,7 @@ export declare class SSRPlaceholderHandlers {
31
31
  isPlaceholderV4(element: HTMLElement): boolean;
32
32
  isPlaceholderReplacementV4(element: HTMLElement): boolean;
33
33
  findNearestPlaceholderContainerIfIgnored(element: HTMLElement): HTMLElement;
34
+ findNearestPlaceholderOrContainer(element: HTMLElement, limit?: number): HTMLElement;
34
35
  checkIfExistedAndSizeMatching(el: HTMLElement): Promise<boolean>;
35
36
  checkIfExistedAndSizeMatchingV3(el: HTMLElement): boolean;
36
37
  getSize(el: HTMLElement): Promise<Rect>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "4.15.10",
3
+ "version": "4.15.12",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -128,6 +128,9 @@
128
128
  "platform_ufo_segment_critical_metrics": {
129
129
  "type": "boolean"
130
130
  },
131
+ "platform_ufo_v4_fix_nested_ssr_placeholder": {
132
+ "type": "boolean"
133
+ },
131
134
  "platform_ufo_add_segments_count_threshold": {
132
135
  "type": "boolean"
133
136
  },