-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use Query directly in finders in order to get rid of build selector - breaking: ignore trailing spaces in selectors - restore comma-separated exception
- Loading branch information
Showing
18 changed files
with
1,242 additions
and
739 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Query } from './query'; | ||
|
||
/** | ||
* @public | ||
* | ||
* Builds a CSS selector from a target selector and a PageObject or a node in a PageObject, along with optional parameters. | ||
* | ||
* @example | ||
* | ||
* const component = PageObject.create({ scope: '.component'}); | ||
* | ||
* buildSelector(component, '.my-element'); | ||
* // returns '.component .my-element' | ||
* | ||
* @example | ||
* | ||
* const page = PageObject.create({}); | ||
* | ||
* buildSelector(page, '.my-element', { at: 0 }); | ||
* // returns '.my-element:eq(0)' | ||
* | ||
* @example | ||
* | ||
* const page = PageObject.create({}); | ||
* | ||
* buildSelector(page, '.my-element', { contains: "Example" }); | ||
* // returns ".my-element :contains('Example')" | ||
* | ||
* @example | ||
* | ||
* const page = PageObject.create({}); | ||
* | ||
* buildSelector(page, '.my-element', { last: true }); | ||
* // returns '.my-element:last' | ||
* | ||
* @param {Ceibo} node - Node of the tree | ||
* @param {string} targetSelector - CSS selector | ||
* @param {Object} options - Additional options | ||
* @param {boolean} options.resetScope - Do not use inherited scope | ||
* @param {string} options.contains - Filter by using :contains('foo') pseudo-class | ||
* @param {number} options.at - Filter by index using :eq(x) pseudo-class | ||
* @param {boolean} options.last - Filter by using :last pseudo-class | ||
* @param {boolean} options.visible - Filter by using :visible pseudo-class | ||
* @return {string} Fully qualified selector | ||
*/ | ||
|
||
export function buildSelector(node, targetSelector, options) { | ||
const q = new Query(node, { | ||
...options, | ||
selector: targetSelector, | ||
}); | ||
|
||
return q.toString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.