@merkur/integration-react 0.29.3 → 0.30.0

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/lib/index.es9.cjs CHANGED
@@ -3,43 +3,34 @@
3
3
  Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  });
6
-
7
6
  var React = require('react');
8
-
9
7
  var core = require('@merkur/core');
10
-
11
8
  var integration = require('@merkur/integration');
12
-
13
9
  function _interopDefaultLegacy(e) {
14
10
  return e && typeof e === 'object' && 'default' in e ? e : {
15
11
  'default': e
16
12
  };
17
13
  }
18
-
19
14
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
20
-
21
15
  function _extends() {
22
- _extends = Object.assign || function (target) {
16
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
23
17
  for (var i = 1; i < arguments.length; i++) {
24
18
  var source = arguments[i];
25
-
26
19
  for (var key in source) {
27
20
  if (Object.prototype.hasOwnProperty.call(source, key)) {
28
21
  target[key] = source[key];
29
22
  }
30
23
  }
31
24
  }
32
-
33
25
  return target;
34
26
  };
35
-
36
27
  return _extends.apply(this, arguments);
37
28
  }
38
-
39
29
  const SelectorIdentifierMap = Object.freeze({
40
30
  '#': 'id',
41
31
  '.': 'className'
42
32
  });
33
+
43
34
  /**
44
35
  * Parses container selector into element property. Currently
45
36
  * only works with IDs and classnames.
@@ -47,28 +38,24 @@ const SelectorIdentifierMap = Object.freeze({
47
38
  * @param {string} [containerSelector='']
48
39
  * @return {{ string: string }} Property name and value tuple.
49
40
  */
50
-
51
41
  function selectorToAttribute(containerSelector = '') {
52
42
  if (typeof containerSelector !== 'string' || containerSelector.length === 0) {
53
43
  return {};
54
44
  }
55
-
56
45
  let lastIdentifierIndex = -1;
57
-
58
46
  for (let identifierKey in SelectorIdentifierMap) {
59
47
  let curLastIndex = containerSelector.lastIndexOf(identifierKey);
60
-
61
48
  if (lastIdentifierIndex < curLastIndex) {
62
49
  lastIdentifierIndex = curLastIndex;
63
50
  }
64
51
  }
65
-
66
52
  const identifier = containerSelector[lastIdentifierIndex];
67
53
  const selectorName = containerSelector.substr(lastIdentifierIndex + 1);
68
54
  return {
69
55
  [SelectorIdentifierMap[identifier]]: selectorName
70
56
  };
71
57
  }
58
+
72
59
  /**
73
60
  * Returns empty <div> with SSR html as it's contents (if provided) and
74
61
  * container selector defined, which is used as merkur widget wrapper.
@@ -76,8 +63,6 @@ function selectorToAttribute(containerSelector = '') {
76
63
  * @param {{ html, containerSelector, children }}
77
64
  * @return {import('react').ReactElement}
78
65
  */
79
-
80
-
81
66
  function WidgetWrapper({
82
67
  html,
83
68
  containerSelector,
@@ -90,9 +75,7 @@ function WidgetWrapper({
90
75
  }
91
76
  })) : /*#__PURE__*/React__default["default"].createElement("div", selector, children);
92
77
  }
93
-
94
78
  var WidgetWrapper$1 = /*#__PURE__*/React__default["default"].memo(WidgetWrapper);
95
-
96
79
  class AbstractMerkurWidget extends React__default["default"].Component {
97
80
  /**
98
81
  * Checks if widget has changed, e.g has different name or version.
@@ -104,51 +87,45 @@ class AbstractMerkurWidget extends React__default["default"].Component {
104
87
  static hasWidgetChanged(props, nextProps) {
105
88
  return !!(props && props.name && props.version && nextProps && nextProps.name && nextProps.version && (props.version !== nextProps.version || props.name !== nextProps.name));
106
89
  }
90
+
107
91
  /**
108
92
  * Validates widget properties, widget properties should not be an empty object.
109
93
  *
110
94
  * @param {object} widgetProperties
111
95
  * @return {boolean} validation result.
112
96
  */
113
-
114
-
115
97
  static validateProperties(widgetProperties) {
116
98
  return !!(widgetProperties && widgetProperties.name && widgetProperties.version);
117
99
  }
100
+
118
101
  /**
119
102
  * Widget SSR rendered html (from server response).
120
103
  */
121
-
122
-
123
104
  get html() {
124
105
  throw new Error('The html getter is abstract and must be overridden');
125
106
  }
107
+
126
108
  /**
127
109
  * Widget container element.
128
110
  */
129
-
130
-
131
111
  get container() {
132
112
  throw new Error('The container getter is abstract and must be overridden');
133
113
  }
134
-
135
114
  constructor(props) {
136
115
  super(props);
137
116
  this._isMounted = false;
138
117
  this._html = null;
139
118
  }
140
-
141
119
  componentDidMount() {
142
120
  this._isMounted = true;
143
121
  }
122
+
144
123
  /**
145
124
  * Renders fallback (children) when widget is already mounted
146
125
  * but not ready or any error has occurred.
147
126
  *
148
127
  * @return {React.ReactElement|null}
149
128
  */
150
-
151
-
152
129
  _renderFallback() {
153
130
  const {
154
131
  children
@@ -156,7 +133,6 @@ class AbstractMerkurWidget extends React__default["default"].Component {
156
133
  const {
157
134
  encounteredError = null
158
135
  } = this.state || {};
159
-
160
136
  if (typeof children === 'function') {
161
137
  return children({
162
138
  error: encounteredError
@@ -164,90 +140,76 @@ class AbstractMerkurWidget extends React__default["default"].Component {
164
140
  } else if ( /*#__PURE__*/React__default["default"].isValidElement(children)) {
165
141
  return children;
166
142
  }
167
-
168
143
  return null;
169
144
  }
145
+
170
146
  /**
171
147
  * Clears cached SSR rendered html.
172
148
  */
173
-
174
-
175
149
  _clearCachedHtml() {
176
150
  this._html = null;
177
151
  }
152
+
178
153
  /**
179
154
  * @return {boolean} true in browser environment.
180
155
  */
181
-
182
-
183
156
  _isClient() {
184
157
  return typeof window !== 'undefined' && typeof document !== 'undefined';
185
158
  }
159
+
186
160
  /**
187
161
  * @return {string} SSR rendered HTML, html from widgetProperties or ''.
188
162
  */
189
-
190
-
191
163
  _getWidgetHTML() {
192
164
  if (this._html !== null) {
193
165
  return this._html;
194
166
  }
195
-
196
167
  this._html = this.html || this._getSSRHTML();
197
168
  return this._html;
198
169
  }
170
+
199
171
  /**
200
172
  * Return server-side rendered html, if its the first render on client
201
173
  * after SSR.
202
174
  *
203
175
  * @return {string} server-side rendered html, if it's not available, return empty string.
204
176
  */
205
-
206
-
207
177
  _getSSRHTML() {
208
178
  if (!this._isMounted && this._isClient()) {
209
179
  var _this$container, _this$container$child, _this$container$child2;
210
-
211
180
  return ((_this$container = this.container) === null || _this$container === void 0 ? void 0 : (_this$container$child = _this$container.children) === null || _this$container$child === void 0 ? void 0 : (_this$container$child2 = _this$container$child[0]) === null || _this$container$child2 === void 0 ? void 0 : _this$container$child2.outerHTML) || '';
212
181
  }
213
-
214
182
  return '';
215
183
  }
184
+
216
185
  /**
217
186
  * Checks if it's the first render after SSR.
218
187
  *
219
188
  * @return {boolean} true in case of a first render after SSR, otherwise false.
220
189
  */
221
-
222
-
223
190
  _isSSRHydrate() {
224
191
  return this._getSSRHTML().length > 0;
225
192
  }
226
-
227
193
  }
228
194
 
195
+ // error event name from @merkur/plugin-error
229
196
  const MERKUR_ERROR_EVENT_NAME = '@merkur/plugin-error.error';
230
-
231
197
  class MerkurWidget extends AbstractMerkurWidget {
232
198
  /**
233
199
  * @inheritdoc
234
200
  */
235
201
  get html() {
236
202
  var _this$props$widgetPro;
237
-
238
203
  return ((_this$props$widgetPro = this.props.widgetProperties) === null || _this$props$widgetPro === void 0 ? void 0 : _this$props$widgetPro.html) || null;
239
204
  }
205
+
240
206
  /**
241
207
  * @inheritdoc
242
208
  */
243
-
244
-
245
209
  get container() {
246
210
  var _document, _this$props$widgetPro2;
247
-
248
211
  return this._isClient() && ((_document = document) === null || _document === void 0 ? void 0 : _document.querySelector((_this$props$widgetPro2 = this.props.widgetProperties) === null || _this$props$widgetPro2 === void 0 ? void 0 : _this$props$widgetPro2.containerSelector)) || null;
249
212
  }
250
-
251
213
  constructor(props) {
252
214
  super(props);
253
215
  this._widget = null;
@@ -258,6 +220,7 @@ class MerkurWidget extends AbstractMerkurWidget {
258
220
  cachedWidgetMeta: null
259
221
  };
260
222
  }
223
+
261
224
  /**
262
225
  * In case widget props change to new widget, we need to reset
263
226
  * state before next render. This enables us to immediately render
@@ -266,15 +229,14 @@ class MerkurWidget extends AbstractMerkurWidget {
266
229
  * @param {object} nextProps
267
230
  * @param {object} prevState
268
231
  */
269
-
270
-
271
232
  static getDerivedStateFromProps(nextProps, prevState) {
272
233
  if (prevState && nextProps && AbstractMerkurWidget.validateProperties(nextProps.widgetProperties)) {
273
234
  const {
274
235
  version,
275
236
  name
276
- } = nextProps.widgetProperties; // Cache widget meta data (name & version)
237
+ } = nextProps.widgetProperties;
277
238
 
239
+ // Cache widget meta data (name & version)
278
240
  if (!prevState.cachedWidgetMeta) {
279
241
  return {
280
242
  cachedWidgetMeta: {
@@ -282,9 +244,9 @@ class MerkurWidget extends AbstractMerkurWidget {
282
244
  version
283
245
  }
284
246
  };
285
- } // Replace cached widget meta data with new ones and reset state
286
-
247
+ }
287
248
 
249
+ // Replace cached widget meta data with new ones and reset state
288
250
  if (AbstractMerkurWidget.hasWidgetChanged(prevState.cachedWidgetMeta, nextProps.widgetProperties)) {
289
251
  return {
290
252
  encounteredError: false,
@@ -296,9 +258,9 @@ class MerkurWidget extends AbstractMerkurWidget {
296
258
  };
297
259
  }
298
260
  }
299
-
300
261
  return null;
301
262
  }
263
+
302
264
  /**
303
265
  * Component should be updated only in these cases:
304
266
  * 1) State of MerkurWidget has changed (excluding { @code this.state.cachedWidgetMeta }).
@@ -312,13 +274,10 @@ class MerkurWidget extends AbstractMerkurWidget {
312
274
  * @param {object} nextProps
313
275
  * @param {object} nextState
314
276
  */
315
-
316
-
317
277
  shouldComponentUpdate(nextProps, nextState) {
318
278
  if (this.state.assetsLoaded !== nextState.assetsLoaded || this.state.encounteredError !== nextState.encounteredError || !AbstractMerkurWidget.validateProperties(this.props.widgetProperties) || AbstractMerkurWidget.hasWidgetChanged(this.props.widgetProperties, nextProps.widgetProperties)) {
319
279
  return true;
320
280
  }
321
-
322
281
  if (this._widget && nextProps.widgetProperties && nextProps.widgetProperties.props) {
323
282
  if (Object.keys(nextProps.widgetProperties.props).length !== Object.keys(this.props.widgetProperties.props).length) {
324
283
  /**
@@ -327,7 +286,6 @@ class MerkurWidget extends AbstractMerkurWidget {
327
286
  * comparison below would not work.
328
287
  */
329
288
  this._widget.setProps(nextProps.widgetProperties.props);
330
-
331
289
  return false;
332
290
  } else {
333
291
  /**
@@ -337,43 +295,37 @@ class MerkurWidget extends AbstractMerkurWidget {
337
295
  for (let key in nextProps.widgetProperties.props) {
338
296
  if (!this.props.widgetProperties || !this.props.widgetProperties.props || nextProps.widgetProperties.props[key] !== this.props.widgetProperties.props[key]) {
339
297
  this._widget.setProps(nextProps.widgetProperties.props);
340
-
341
298
  return false;
342
299
  }
343
300
  }
344
301
  }
345
302
  }
346
-
347
303
  if (this._widget && nextProps.widgetProperties && nextProps.widgetProperties.state) {
348
304
  if (Object.keys(nextProps.widgetProperties.state).length !== Object.keys(this.props.widgetProperties.state).length) {
349
305
  this._widget.setState(nextProps.widgetProperties.state);
350
-
351
306
  return false;
352
307
  } else {
353
308
  for (let key in nextProps.widgetProperties.state) {
354
309
  if (!this.props.widgetProperties || !this.props.widgetProperties.state || nextProps.widgetProperties.state[key] !== this.props.widgetProperties.state[key]) {
355
310
  this._widget.setState(nextProps.widgetProperties.state);
356
-
357
311
  return false;
358
312
  }
359
313
  }
360
314
  }
361
315
  }
362
-
363
316
  return false;
364
317
  }
318
+
365
319
  /**
366
320
  * In case of mounting the component, we always try to first load
367
321
  * the widget assets. Be it first mount after SSR or mount after
368
322
  * first render on client.
369
323
  */
370
-
371
-
372
324
  componentDidMount() {
373
325
  super.componentDidMount();
374
-
375
326
  this._loadWidgetAssets();
376
327
  }
328
+
377
329
  /**
378
330
  * After the component has been updated, we still need to handle few situations.
379
331
  * 1) In case assets have been loaded, we need to mount the widget.
@@ -382,24 +334,22 @@ class MerkurWidget extends AbstractMerkurWidget {
382
334
  * @param {object} prevProps
383
335
  * @param {object} prevState
384
336
  */
385
-
386
-
387
337
  componentDidUpdate(prevProps, prevState) {
388
338
  const {
389
339
  widgetProperties: currentWidgetProperties
390
340
  } = this.props;
391
341
  const {
392
342
  widgetProperties: prevWidgetProperties
393
- } = prevProps; // 1) Assets have been loaded => mount the widget
343
+ } = prevProps;
394
344
 
345
+ // 1) Assets have been loaded => mount the widget
395
346
  if (this.state.assetsLoaded && prevState.assetsLoaded !== this.state.assetsLoaded) {
396
347
  return this._mountWidget();
397
- } // 2.1) In case we receive empty new properties, we need to cleanup.
398
-
348
+ }
399
349
 
350
+ // 2.1) In case we receive empty new properties, we need to cleanup.
400
351
  if (!AbstractMerkurWidget.validateProperties(currentWidgetProperties) && AbstractMerkurWidget.validateProperties(prevWidgetProperties)) {
401
352
  this._removeWidget();
402
-
403
353
  this.setState({
404
354
  encounteredError: false,
405
355
  assetsLoaded: false,
@@ -407,39 +357,35 @@ class MerkurWidget extends AbstractMerkurWidget {
407
357
  });
408
358
  return;
409
359
  }
360
+
410
361
  /**
411
362
  * 2.2) In case there were no widget properties before, we try to
412
363
  * initialize widget first by doing the same as if it first mounted
413
364
  * (loading assets into the DOM).
414
365
  */
415
-
416
-
417
366
  if (AbstractMerkurWidget.validateProperties(currentWidgetProperties) && !AbstractMerkurWidget.validateProperties(prevWidgetProperties)) {
418
367
  return this._loadWidgetAssets();
419
368
  }
369
+
420
370
  /**
421
371
  * 2.3) In case widget has changed, first we need to cleanup (remove previous widget),
422
372
  * and then we again try to initialize the new widget same way as
423
373
  * if it has mounted for the first time (if there are any new widget properties).
424
374
  */
425
-
426
-
427
375
  if (AbstractMerkurWidget.hasWidgetChanged(currentWidgetProperties, prevWidgetProperties)) {
428
376
  this._removeWidget();
429
-
430
377
  this._loadWidgetAssets();
431
-
432
378
  return;
433
379
  }
434
380
  }
381
+
435
382
  /**
436
383
  * In case of unmounting we only really need to do the cleanup.
437
384
  */
438
-
439
-
440
385
  componentWillUnmount() {
441
386
  this._removeWidget();
442
387
  }
388
+
443
389
  /**
444
390
  * There are two possible outputs from the render method:
445
391
  * 1) Fallback is rendered only, when assets are not yet loaded
@@ -450,8 +396,6 @@ class MerkurWidget extends AbstractMerkurWidget {
450
396
  *
451
397
  * @return {React.ReactElement|null}
452
398
  */
453
-
454
-
455
399
  render() {
456
400
  const {
457
401
  widgetProperties
@@ -460,30 +404,25 @@ class MerkurWidget extends AbstractMerkurWidget {
460
404
  encounteredError,
461
405
  assetsLoaded
462
406
  } = this.state;
463
-
464
407
  if (!AbstractMerkurWidget.validateProperties(widgetProperties) || encounteredError || this._isClient() && !this._isSSRHydrate() && !assetsLoaded) {
465
408
  return this._renderFallback();
466
409
  }
467
-
468
410
  if (!widgetProperties.containerSelector) {
469
411
  throw new Error(`The widgetProperties.containerSelector is not defined`);
470
412
  }
471
-
472
413
  const html = this._getWidgetHTML();
473
-
474
414
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, (!this._isClient() || this._isSSRHydrate()) && this._renderStyleAssets(), /*#__PURE__*/React__default["default"].createElement(WidgetWrapper$1, {
475
415
  containerSelector: widgetProperties.containerSelector,
476
416
  html: html
477
417
  }));
478
418
  }
419
+
479
420
  /**
480
421
  * Renders widget style assets inline. This is used on SSR
481
422
  * and in first render after SSR hydration.
482
423
  *
483
424
  * @return {[React.ReactElement]}
484
425
  */
485
-
486
-
487
426
  _renderStyleAssets() {
488
427
  const {
489
428
  widgetProperties
@@ -497,7 +436,6 @@ class MerkurWidget extends AbstractMerkurWidget {
497
436
  href: asset.source,
498
437
  key: key
499
438
  });
500
-
501
439
  case 'inlineStyle':
502
440
  return /*#__PURE__*/React__default["default"].createElement("style", {
503
441
  key: key,
@@ -508,56 +446,46 @@ class MerkurWidget extends AbstractMerkurWidget {
508
446
  }
509
447
  });
510
448
  }
511
-
512
449
  _handleError(error) {
513
- if (typeof this.props.onError === 'function') {
514
- this.props.onError(error);
450
+ if (typeof this.props.onError === 'function' && this.props.onError(error)) {
451
+ return;
515
452
  }
516
-
517
453
  this.setState({
518
454
  encounteredError: error
519
455
  });
520
456
  }
457
+
521
458
  /**
522
459
  * Handles widget unmounting and removal, while removing
523
460
  * event listeners, calling unmount on props and widget.
524
461
  */
525
-
526
-
527
462
  _removeWidget() {
528
463
  if (!this._widget) {
529
464
  return;
530
465
  }
531
-
532
466
  if (this.props.onWidgetUnmounting) {
533
467
  this.props.onWidgetUnmounting(this._widget);
534
- } // widget might not be using @merkur/plugin-event-emitter
535
-
468
+ }
536
469
 
470
+ // widget might not be using @merkur/plugin-event-emitter
537
471
  if (typeof this._widget.off === 'function') {
538
472
  this._widget.off(MERKUR_ERROR_EVENT_NAME, this._handleClientError);
539
473
  }
540
-
541
474
  this._widget.unmount();
542
-
543
475
  this._widget = null;
544
-
545
476
  this._clearCachedHtml();
546
477
  }
478
+
547
479
  /**
548
480
  * Loads widget assets into page.
549
481
  */
550
-
551
-
552
482
  _loadWidgetAssets() {
553
483
  const {
554
484
  widgetProperties
555
485
  } = this.props;
556
-
557
486
  if (!AbstractMerkurWidget.validateProperties(widgetProperties) || this._widget) {
558
487
  return;
559
488
  }
560
-
561
489
  return Promise.all([integration.loadStyleAssets(widgetProperties.assets), integration.loadScriptAssets(widgetProperties.assets)]).then(() => new Promise(resolve => {
562
490
  this.setState({
563
491
  assetsLoaded: true
@@ -566,32 +494,27 @@ class MerkurWidget extends AbstractMerkurWidget {
566
494
  });
567
495
  })).catch(error => this._handleError(error));
568
496
  }
497
+
569
498
  /**
570
499
  * Creates and mounts widget instance after all resource loaded.
571
500
  */
572
-
573
-
574
501
  async _mountWidget() {
575
502
  const {
576
503
  widgetProperties,
577
504
  onWidgetMounted,
578
505
  debug = false
579
506
  } = this.props;
580
-
581
507
  if (!AbstractMerkurWidget.validateProperties(widgetProperties) || this._widget) {
582
508
  return;
583
509
  }
584
-
585
510
  try {
586
511
  const merkur = core.getMerkur();
587
512
  this._widget = await merkur.create(widgetProperties);
588
513
  await this._widget.mount();
589
-
590
514
  if (typeof this._widget.on === 'function') {
591
515
  // widget might not be using @merkur/plugin-event-emitter
592
516
  this._widget.on(MERKUR_ERROR_EVENT_NAME, this._handleClientError);
593
517
  }
594
-
595
518
  if (typeof onWidgetMounted === 'function') {
596
519
  onWidgetMounted(this._widget);
597
520
  }
@@ -601,9 +524,7 @@ class MerkurWidget extends AbstractMerkurWidget {
601
524
  }
602
525
  }
603
526
  }
604
-
605
527
  }
606
-
607
528
  class MerkurSlot extends AbstractMerkurWidget {
608
529
  /**
609
530
  * Returns access to current slot properties, based on it's name
@@ -611,33 +532,29 @@ class MerkurSlot extends AbstractMerkurWidget {
611
532
  */
612
533
  get slot() {
613
534
  var _widgetProperties$slo, _widgetProperties$slo2;
614
-
615
535
  const {
616
536
  widgetProperties,
617
537
  slotName
618
538
  } = this.props;
619
539
  return (_widgetProperties$slo = widgetProperties === null || widgetProperties === void 0 ? void 0 : (_widgetProperties$slo2 = widgetProperties.slot) === null || _widgetProperties$slo2 === void 0 ? void 0 : _widgetProperties$slo2[slotName]) !== null && _widgetProperties$slo !== void 0 ? _widgetProperties$slo : null;
620
540
  }
541
+
621
542
  /**
622
543
  * @inheritdoc
623
544
  */
624
-
625
-
626
545
  get html() {
627
546
  var _this$slot;
628
-
629
547
  return ((_this$slot = this.slot) === null || _this$slot === void 0 ? void 0 : _this$slot.html) || null;
630
548
  }
549
+
631
550
  /**
632
551
  * @inheritdoc
633
552
  */
634
-
635
-
636
553
  get container() {
637
554
  var _document2, _this$slot2;
638
-
639
555
  return this._isClient() && ((_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.querySelector((_this$slot2 = this.slot) === null || _this$slot2 === void 0 ? void 0 : _this$slot2.containerSelector)) || null;
640
556
  }
557
+
641
558
  /**
642
559
  * The component should update only in following cases:
643
560
  * 1) Component has no props.widgetProperties.
@@ -645,23 +562,19 @@ class MerkurSlot extends AbstractMerkurWidget {
645
562
  *
646
563
  * @param {object} nextProps
647
564
  */
648
-
649
-
650
565
  shouldComponentUpdate(nextProps) {
651
566
  if (!AbstractMerkurWidget.validateProperties(this.props.widgetProperties) || !AbstractMerkurWidget.validateProperties(nextProps.widgetProperties) || AbstractMerkurWidget.hasWidgetChanged(this.props.widgetProperties, nextProps.widgetProperties)) {
652
567
  return true;
653
568
  }
654
-
655
569
  return false;
656
570
  }
571
+
657
572
  /**
658
573
  * Cleanup when we receive empty widget properties.
659
574
  *
660
575
  * @param {object} prevProps
661
576
  * @param {object} prevState
662
577
  */
663
-
664
-
665
578
  componentDidUpdate(prevProps) {
666
579
  const {
667
580
  widgetProperties: currentWidgetProperties
@@ -669,21 +582,19 @@ class MerkurSlot extends AbstractMerkurWidget {
669
582
  const {
670
583
  widgetProperties: prevWidgetProperties
671
584
  } = prevProps;
672
-
673
585
  if (!AbstractMerkurWidget.validateProperties(currentWidgetProperties) && AbstractMerkurWidget.validateProperties(prevWidgetProperties)) {
674
586
  this._removeSlot();
675
-
676
587
  return;
677
588
  }
678
589
  }
590
+
679
591
  /**
680
592
  * Cleanup when unmounting
681
593
  */
682
-
683
-
684
594
  componentWillUnmount() {
685
595
  this._removeSlot();
686
596
  }
597
+
687
598
  /**
688
599
  * There are two possible outputs from the render method:
689
600
  * 1) Fallback is rendered only, when there are no widget properties.
@@ -693,20 +604,17 @@ class MerkurSlot extends AbstractMerkurWidget {
693
604
  *
694
605
  * @return {React.ReactElement|null}
695
606
  */
696
-
697
-
698
607
  render() {
699
608
  const {
700
609
  widgetProperties
701
610
  } = this.props;
702
-
703
611
  if (!AbstractMerkurWidget.validateProperties(widgetProperties) || !this.slot) {
704
612
  return this._renderFallback();
705
613
  }
706
-
707
614
  if (!this.slot['containerSelector']) {
708
615
  throw new Error(`The ${this.slot.name}.containerSelector is not defined`);
709
616
  }
617
+
710
618
  /**
711
619
  * In case of SPA rendering, we render fallback (which can also display
712
620
  * loading placeholders) inside the component wrapper, until the widget
@@ -714,8 +622,6 @@ class MerkurSlot extends AbstractMerkurWidget {
714
622
  * of the wrapper (containing fallback) with slot markup. In case of SPA
715
623
  * we also don't want to render html to prevent FOUC.
716
624
  */
717
-
718
-
719
625
  const isInitialSPARender = this._isClient() && !this._isSSRHydrate();
720
626
  const html = isInitialSPARender ? '' : this._getWidgetHTML();
721
627
  return /*#__PURE__*/React__default["default"].createElement(WidgetWrapper$1, {
@@ -723,16 +629,13 @@ class MerkurSlot extends AbstractMerkurWidget {
723
629
  html: html
724
630
  }, isInitialSPARender && this._renderFallback());
725
631
  }
632
+
726
633
  /**
727
634
  * Cleanup after slot removal.
728
635
  */
729
-
730
-
731
636
  _removeSlot() {
732
637
  this._clearCachedHtml();
733
638
  }
734
-
735
639
  }
736
-
737
640
  exports.MerkurSlot = MerkurSlot;
738
641
  exports.MerkurWidget = MerkurWidget;