@atlaskit/react-ufo 4.15.10 → 4.15.11

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,27 @@ 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 ancestor = element;
249
+ if (this.isPlaceholderIgnored(element) && element.parentElement) {
250
+ ancestor = element.parentElement;
251
+ }
252
+ var i = 0;
253
+ while (ancestor && i < ANCESTOR_LOOKUP_LIMIT) {
254
+ if (this.isPlaceholder(ancestor) || this.isPlaceholderReplacement(ancestor)) {
255
+ return ancestor;
256
+ }
257
+ if (ancestor.parentElement) {
258
+ ancestor = ancestor.parentElement;
259
+ i++;
260
+ } else {
261
+ break;
262
+ }
263
+ }
264
+ return element;
265
+ }
245
266
 
246
267
  // Validates placeholder match using asynchronous observation and resolves with the result
247
268
  }, {
@@ -304,7 +325,7 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
304
325
  }, {
305
326
  key: "validateReactComponentMatchToPlaceholderV4",
306
327
  value: function validateReactComponentMatchToPlaceholderV4(el) {
307
- el = this.findNearestPlaceholderContainerIfIgnored(el);
328
+ el = (0, _platformFeatureFlags.fg)('platform_ufo_v4_fix_nested_ssr_placeholder') ? this.findNearestPlaceholderOrContainer(el) : this.findNearestPlaceholderContainerIfIgnored(el);
308
329
  var id = this.getPlaceholderReplacementId(el);
309
330
  return this.staticPlaceholders.has(id);
310
331
  }
@@ -209,6 +209,25 @@ export class SSRPlaceholderHandlers {
209
209
  }
210
210
  return element;
211
211
  }
212
+ findNearestPlaceholderOrContainer(element) {
213
+ let ancestor = element;
214
+ if (this.isPlaceholderIgnored(element) && element.parentElement) {
215
+ ancestor = element.parentElement;
216
+ }
217
+ let i = 0;
218
+ while (ancestor && i < ANCESTOR_LOOKUP_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,7 @@ 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) : this.findNearestPlaceholderContainerIfIgnored(el);
262
281
  const id = this.getPlaceholderReplacementId(el);
263
282
  return this.staticPlaceholders.has(id);
264
283
  }
@@ -235,6 +235,27 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
235
235
  }
236
236
  return element;
237
237
  }
238
+ }, {
239
+ key: "findNearestPlaceholderOrContainer",
240
+ value: function findNearestPlaceholderOrContainer(element) {
241
+ var ancestor = element;
242
+ if (this.isPlaceholderIgnored(element) && element.parentElement) {
243
+ ancestor = element.parentElement;
244
+ }
245
+ var i = 0;
246
+ while (ancestor && i < ANCESTOR_LOOKUP_LIMIT) {
247
+ if (this.isPlaceholder(ancestor) || this.isPlaceholderReplacement(ancestor)) {
248
+ return ancestor;
249
+ }
250
+ if (ancestor.parentElement) {
251
+ ancestor = ancestor.parentElement;
252
+ i++;
253
+ } else {
254
+ break;
255
+ }
256
+ }
257
+ return element;
258
+ }
238
259
 
239
260
  // Validates placeholder match using asynchronous observation and resolves with the result
240
261
  }, {
@@ -297,7 +318,7 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
297
318
  }, {
298
319
  key: "validateReactComponentMatchToPlaceholderV4",
299
320
  value: function validateReactComponentMatchToPlaceholderV4(el) {
300
- el = this.findNearestPlaceholderContainerIfIgnored(el);
321
+ el = fg('platform_ufo_v4_fix_nested_ssr_placeholder') ? this.findNearestPlaceholderOrContainer(el) : this.findNearestPlaceholderContainerIfIgnored(el);
301
322
  var id = this.getPlaceholderReplacementId(el);
302
323
  return this.staticPlaceholders.has(id);
303
324
  }
@@ -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): 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): 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.11",
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
  },