webdriverio 8.34.0 → 8.34.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.
@@ -1 +1 @@
1
- {"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/$$.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAsB,EAAE,CACpB,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,EAC/C,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,EAAE,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,WAAW,EAAE,qCAmBlF"}
1
+ {"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/$$.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAsB,EAAE,CACpB,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,EAC/C,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,EAAE,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,WAAW,EAAE,qCAiClF"}
@@ -1,5 +1,5 @@
1
1
  import { findElements, enhanceElementsArray, isElement, findElement } from '../../utils/index.js';
2
- import { getElements } from '../../utils/getElementObject.js';
2
+ import { getElements, getElement } from '../../utils/getElementObject.js';
3
3
  /**
4
4
  * The `$$` command is a short and handy way in order to fetch multiple elements on the page.
5
5
  * It returns a `ChainablePromiseArray` containing a set of WebdriverIO elements.
@@ -54,6 +54,19 @@ export async function $$(selector) {
54
54
  $el && res.push($el);
55
55
  }
56
56
  }
57
+ /**
58
+ * Define scope of element. In most cases it is `this` but if we pass through
59
+ * an element object from the browser runner we have to look into the parent
60
+ * provided by the selector object. Since these objects are passed through
61
+ * as raw objects without any prototype we have to check if the `$` or `$$`
62
+ * is defined on the object itself and if not, create a new element object.
63
+ */
64
+ let parent = res.length > 0 ? res[0].parent || this : this;
65
+ if (typeof parent.$ === 'undefined') {
66
+ parent = 'selector' in parent
67
+ ? getElement.call(this, parent.selector, parent)
68
+ : this;
69
+ }
57
70
  const elements = await getElements.call(this, selector, res);
58
- return enhanceElementsArray(elements, this, selector);
71
+ return enhanceElementsArray(elements, parent, selector);
59
72
  }
@@ -97,7 +97,7 @@ export const getElements = function getElements(selector, elemResponse, props =
97
97
  /**
98
98
  * if we already deal with an element, just return it
99
99
  */
100
- if (res.selector) {
100
+ if (res.selector && '$$' in res) {
101
101
  return res;
102
102
  }
103
103
  propertiesObject.scope = { value: 'element' };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "webdriverio",
3
3
  "description": "Next-gen browser and mobile automation test framework for Node.js",
4
- "version": "8.34.0",
4
+ "version": "8.34.1",
5
5
  "homepage": "https://webdriver.io",
6
6
  "author": "Christian Bromann <mail@bromann.dev>",
7
7
  "license": "MIT",
@@ -101,5 +101,5 @@
101
101
  "optional": true
102
102
  }
103
103
  },
104
- "gitHead": "72856f9e3e4c6ae0750a1d3f17b137724a30e4e5"
104
+ "gitHead": "224614b872993c0a3ef196014f1f986af4b08311"
105
105
  }