From e20a4f4936a5f6410f015b8a4f5531d604ce71b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Pereira?= Date: Mon, 4 Dec 2023 12:52:09 +0100 Subject: [PATCH] Rename AsyncSelector to buildAsyncSelector (#9) * Rename AsyncSelector to buildAsyncSelector * Add the buildAsyncSelector change to the documentation --- CHANGELOG.md | 4 ++++ README.md | 18 ++++++++--------- cypress/e2e/async-selector.spec.cy.ts | 28 +++++++++++++-------------- src/index.ts | 6 +++--- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c8e87f..1912e5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [2.0.2] - 2023-12-04 + +- `AsyncSelector` has been renamed to `buildAsyncSelector` + ## [2.0.1] - 2023-12-04 - Export `AsyncParams` and `AsyncSelectorProxy` diff --git a/README.md b/README.md index f6d5b88..0e00cc5 100644 --- a/README.md +++ b/README.md @@ -119,9 +119,9 @@ asyncQuerySelectorAll('article$ div$ p') }); // Using async dot notation -import { AsyncSelector } from 'shadow-dom-selector'; +import { buildAsyncSelector } from 'shadow-dom-selector'; -const selector = AsyncSelector(); +const selector = buildAsyncSelector(); selector.article.$.div.$.element .then((shadowRoot) => { @@ -184,7 +184,7 @@ ShadowDomSelector.shadowRootQuerySelector; ShadowDomSelector.asyncQuerySelector; ShadowDomSelector.asyncQuerySelectorAll; ShadowDomSelector.asyncShadowRootQuerySelector; -ShadowDomSelector.AsyncSelector; +ShadowDomSelector.buildAsyncSelector; ``` ## API @@ -330,14 +330,14 @@ asyncShadowRootQuerySelector(root, selectors, asyncParams): Promise { +describe('ShadowDomSelector buildAsyncSelector class spec', () => { beforeEach(() => { cy.visit('http://localhost:3000'); @@ -9,9 +9,9 @@ describe('ShadowDomSelector AsyncSelector class spec', () => { .then(async (win) => { const doc = win.document; - const AsyncSelector = win.ShadowDomSelector.AsyncSelector; + const buildAsyncSelector = win.ShadowDomSelector.buildAsyncSelector; - const selector = AsyncSelector({ + const selector = buildAsyncSelector({ retries: 1, delay: 5 }); @@ -36,9 +36,9 @@ describe('ShadowDomSelector AsyncSelector class spec', () => { .then(async (win) => { const doc = win.document; - const AsyncSelector = win.ShadowDomSelector.AsyncSelector; + const buildAsyncSelector = win.ShadowDomSelector.buildAsyncSelector; - const selector = AsyncSelector(); + const selector = buildAsyncSelector(); const article = doc .querySelector('section') @@ -79,14 +79,14 @@ describe('ShadowDomSelector AsyncSelector class spec', () => { .then(async (win) => { const doc = win.document; - const AsyncSelector = win.ShadowDomSelector.AsyncSelector; + const buildAsyncSelector = win.ShadowDomSelector.buildAsyncSelector; const article = doc .querySelector('section') .shadowRoot .querySelector('article'); - const selector = AsyncSelector(article); + const selector = buildAsyncSelector(article); expect(await selector.element).to.equal(article); @@ -105,9 +105,9 @@ describe('ShadowDomSelector AsyncSelector class spec', () => { cy.window() .then(async (win) => { - const AsyncSelector = win.ShadowDomSelector.AsyncSelector; + const buildAsyncSelector = win.ShadowDomSelector.buildAsyncSelector; - const selector = AsyncSelector({ + const selector = buildAsyncSelector({ retries: 100 }); @@ -128,9 +128,9 @@ describe('ShadowDomSelector AsyncSelector class spec', () => { cy.window() .then(async (win) => { - const AsyncSelector = win.ShadowDomSelector.AsyncSelector; + const buildAsyncSelector = win.ShadowDomSelector.buildAsyncSelector; - const selector = AsyncSelector({ + const selector = buildAsyncSelector({ retries: 7, delay: 13 }); @@ -152,13 +152,13 @@ describe('ShadowDomSelector AsyncSelector class spec', () => { .then(async (win) => { const doc = win.document; - const AsyncSelector = win.ShadowDomSelector.AsyncSelector; + const buildAsyncSelector = win.ShadowDomSelector.buildAsyncSelector; - const selector = AsyncSelector({ + const selector = buildAsyncSelector({ delay: 5 }); - const selectorFromSection = AsyncSelector( + const selectorFromSection = buildAsyncSelector( doc.querySelector('section').shadowRoot, { delay: 5 diff --git a/src/index.ts b/src/index.ts index 95439ae..1e18001 100644 --- a/src/index.ts +++ b/src/index.ts @@ -186,14 +186,14 @@ export async function asyncShadowRootQuerySelector( ); } -export function AsyncSelector( +export function buildAsyncSelector( asyncParams?: AsyncParams ): AsyncSelectorProxy; -export function AsyncSelector( +export function buildAsyncSelector( root: Document | Element | ShadowRoot, asyncParams?: AsyncParams ): AsyncSelectorProxy; -export function AsyncSelector ( +export function buildAsyncSelector ( firstParameter: Document | Element | ShadowRoot | AsyncParams, secondParameter?: AsyncParams ): AsyncSelectorProxy {