@brndts/brndts-ads 1.13.11 → 1.13.13

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/dist/index.mjs CHANGED
@@ -80187,6 +80187,10 @@ var Interface = /*#__PURE__*/ function(_import_events7_default) {
80187
80187
  value: function setupControls() {
80188
80188
  var _this = this;
80189
80189
  this.controls = new Controls(this.context);
80190
+ var existingControls = this.container.querySelector("#".concat(this.controls.view.id));
80191
+ if (existingControls) {
80192
+ this.container.removeChild(existingControls);
80193
+ }
80190
80194
  this.container.appendChild(this.controls.view);
80191
80195
  this.controls.events.on("TOGGLE_FULLSCREEN", function() {
80192
80196
  _this.fullscreen.toggleFullscreen();
@@ -80232,6 +80236,7 @@ var Interface = /*#__PURE__*/ function(_import_events7_default) {
80232
80236
  if (!this.context.elements.original) {
80233
80237
  var _this_context_elements_container;
80234
80238
  (_this_context_elements_container = this.context.elements.container) === null || _this_context_elements_container === void 0 ? void 0 : _this_context_elements_container.remove();
80239
+ this.context.elements.container = null;
80235
80240
  return;
80236
80241
  }
80237
80242
  (_this_container_parentElement = this.container.parentElement) === null || _this_container_parentElement === void 0 ? void 0 : _this_container_parentElement.replaceChild(this.context.elements.original, this.container);
@@ -82632,6 +82637,12 @@ var VideoAd = /*#__PURE__*/ function() {
82632
82637
  (_this_presentation = this.presentation) === null || _this_presentation === void 0 ? void 0 : _this_presentation.updateSize();
82633
82638
  }
82634
82639
  },
82640
+ {
82641
+ key: "isBroken",
82642
+ value: function isBroken() {
82643
+ return !this.media.view || document.body.contains(this.media.view) || !this.media.view.closest("#BRNDTS_R") || !this.media.view.querySelector("#BRNDTS_R");
82644
+ }
82645
+ },
82635
82646
  {
82636
82647
  key: "destroy",
82637
82648
  value: function destroy() {
@@ -82660,39 +82671,21 @@ var VideoAds = /*#__PURE__*/ function() {
82660
82671
  var elements2 = [];
82661
82672
  for(var index = 0; index < this.videoAdElements.length; index++){
82662
82673
  var element = this.videoAdElements[index];
82663
- if (element.media.view && document.body.contains(element.media.view)) {
82664
- elements2.push(element);
82665
- } else {
82674
+ if (element.isBroken()) {
82666
82675
  element.destroy();
82676
+ } else {
82677
+ elements2.push(element);
82667
82678
  }
82668
82679
  }
82669
82680
  this.videoAdElements = elements2;
82670
82681
  var medias = MediaElementFactory.getElements(this.context.selectors.targets);
82671
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
82672
- try {
82673
- for(var _iterator = medias[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
82674
- var media = _step.value;
82675
- if (!media || media.closest("#BRNDTS_R") || media.querySelector("#BRNDTS_R") || media.dataset.b_I !== void 0) {
82676
- continue;
82677
- }
82678
- media.dataset.b_I = "".concat(this.videoAdElements.length);
82679
- var videoAd = new VideoAd(this.context, media);
82680
- this.videoAdElements.push(videoAd);
82681
- videoAd.start();
82682
- }
82683
- } catch (err) {
82684
- _didIteratorError = true;
82685
- _iteratorError = err;
82686
- } finally{
82687
- try {
82688
- if (!_iteratorNormalCompletion && _iterator.return != null) {
82689
- _iterator.return();
82690
- }
82691
- } finally{
82692
- if (_didIteratorError) {
82693
- throw _iteratorError;
82694
- }
82682
+ for(var index1 = 0; index1 < medias.length; index1++){
82683
+ if (!medias[index1] || medias[index1].closest("#BRNDTS_R") || medias[index1].querySelector("#BRNDTS_R")) {
82684
+ continue;
82695
82685
  }
82686
+ var videoAd = new VideoAd(this.context, medias[index1]);
82687
+ this.videoAdElements.push(videoAd);
82688
+ videoAd.start();
82696
82689
  }
82697
82690
  } catch (error) {
82698
82691
  if (_instanceof(error, Error)) {
@@ -82790,7 +82783,8 @@ var Ads = /*#__PURE__*/ function() {
82790
82783
  this.videoAds.start();
82791
82784
  this.staticAds.start();
82792
82785
  this.observer.observe(document.body, {
82793
- childList: true
82786
+ childList: true,
82787
+ subtree: true
82794
82788
  });
82795
82789
  }
82796
82790
  },