@pendo/agent 2.290.2 → 2.291.1

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/dom.esm.js CHANGED
@@ -5283,6 +5283,16 @@ function isElementShadowRoot(elem, _win) {
5283
5283
  function getParent(elem, _win) {
5284
5284
  return isElementShadowRoot(elem, _win) ? elem.host : elem.parentNode;
5285
5285
  }
5286
+ function contains(context, elem, _win) {
5287
+ var parent = elem;
5288
+ while (parent) {
5289
+ if (parent === context) {
5290
+ return true;
5291
+ }
5292
+ parent = getParent(parent, _win);
5293
+ }
5294
+ return false;
5295
+ }
5286
5296
 
5287
5297
  var shadowAPI = (function () {
5288
5298
  function isShadowSelector(selector) {
@@ -5315,10 +5325,19 @@ var shadowAPI = (function () {
5315
5325
  isElementShadowRoot: isElementShadowRoot,
5316
5326
  getParent: getParent,
5317
5327
  isShadowSelector: isShadowSelector,
5318
- wrapSizzle: function (Sizzle) {
5328
+ wrapSizzle: function (Sizzle, shadowDomManager) {
5319
5329
  Sizzle.intercept(function (Sizzle, selection, context, results, seed) {
5320
5330
  if (!isShadowSelector(selection)) {
5321
- return Sizzle(selection, context, results, seed);
5331
+ var queryResults_1 = Sizzle(selection, context, results, seed);
5332
+ if (shadowDomManager.cache.size > 0) {
5333
+ // eslint-disable-next-line agent-eslint-rules/no-array-foreach
5334
+ shadowDomManager.cache.forEach(function (shadowRoot) {
5335
+ if (!context || context === document || contains(context, shadowRoot)) {
5336
+ queryResults_1.push.apply(queryResults_1, Sizzle(selection, shadowRoot, results, seed));
5337
+ }
5338
+ });
5339
+ }
5340
+ return queryResults_1;
5322
5341
  }
5323
5342
  if (!_.isFunction(document.documentElement.attachShadow)) {
5324
5343
  return Sizzle(selection.replace(shadowAPI.PSEUDO_REGEX, ''), context, results, seed);
@@ -6347,7 +6366,8 @@ var ConfigReader = (function () {
6347
6366
  /**
6348
6367
  * Use this setting when using `preferMutationObserver` with an application that has Shadow DOM elements.
6349
6368
  * On page load, the Agent will run a full document scan for shadow roots and attach a MutationObserver to
6350
- * all results.
6369
+ * all results. This setting also allows the agent to run CSS selectors in all shadow roots, so CSS selectors
6370
+ * can be written without specifying the full path through all shadow roots with the `::shadow` pseudo-class.
6351
6371
  *
6352
6372
  * @access public
6353
6373
  * @category Config/Core
@@ -7292,7 +7312,7 @@ function getScreenPosition(element) {
7292
7312
  };
7293
7313
  }
7294
7314
 
7295
- var VERSION = '2.290.2_';
7315
+ var VERSION = '2.291.1_';
7296
7316
 
7297
7317
  var decodeURIComponent = _.isFunction(window.decodeURIComponent) ? window.decodeURIComponent : _.identity;
7298
7318
 
@@ -8838,32 +8858,35 @@ var getBody = function (_document) {
8838
8858
  * @param {HTMLElement} element
8839
8859
  * @returns {boolean}
8840
8860
  */
8841
- function isInDocument(element) {
8842
- if (SizzleProxy.contains(document, element))
8861
+ function isInDocument(element, doc) {
8862
+ if (doc === void 0) { doc = document; }
8863
+ if (SizzleProxy.contains(doc, element))
8843
8864
  return true;
8844
8865
  while (element && element.parentNode || shadowAPI.isElementShadowRoot(element)) {
8845
8866
  element = shadowAPI.getParent(element);
8846
8867
  }
8847
- return element === document;
8868
+ return element === doc;
8848
8869
  }
8849
8870
  var getClientRect = function (element) {
8850
- var pbody = getBody();
8851
- if (element === null) {
8871
+ if (element == null) {
8852
8872
  return;
8853
8873
  }
8854
- else if ((element === document || element === window)) {
8874
+ var doc = element.ownerDocument || document;
8875
+ var win = doc.defaultView || window;
8876
+ var pbody = getBody(doc);
8877
+ if ((element === doc || element === win)) {
8855
8878
  var viewport = {
8856
- left: window.pageXOffset || pbody.scrollLeft,
8857
- top: window.pageYOffset || pbody.scrollTop,
8858
- width: window.innerWidth,
8859
- height: window.innerHeight
8879
+ left: win.pageXOffset || pbody.scrollLeft,
8880
+ top: win.pageYOffset || pbody.scrollTop,
8881
+ width: win.innerWidth,
8882
+ height: win.innerHeight
8860
8883
  };
8861
8884
  viewport.right = viewport.left + viewport.width;
8862
8885
  viewport.bottom = viewport.top + viewport.height;
8863
8886
  return viewport;
8864
8887
  }
8865
8888
  else {
8866
- var clientRect = getOffsetPosition(element);
8889
+ var clientRect = getOffsetPosition(element, win);
8867
8890
  clientRect.right = clientRect.left + clientRect.width;
8868
8891
  clientRect.bottom = clientRect.top + clientRect.height;
8869
8892
  return clientRect;
@@ -9558,7 +9581,7 @@ DomQuery.$ = {
9558
9581
  if (target && target.parentNode) {
9559
9582
  target.parentNode.insertBefore(this[0], target);
9560
9583
  // Execute scripts (if any) when the fragment enters the document
9561
- if (isInDocument(document)) {
9584
+ if (isInDocument(document, this)) {
9562
9585
  _.each(SizzleProxy('script', this[0]), evalScript);
9563
9586
  }
9564
9587
  }