chore: introduce md templates (#17632)
This commit is contained in:
parent
c25fb04030
commit
bfd38bf7df
|
|
@ -125,7 +125,7 @@ Returns locator to the last matching frame.
|
||||||
* since: v1.17
|
* since: v1.17
|
||||||
- returns: <[Locator]>
|
- returns: <[Locator]>
|
||||||
|
|
||||||
The method finds an element matching the specified selector in the FrameLocator's subtree.
|
%%-template-locator-locator-%%
|
||||||
|
|
||||||
### param: FrameLocator.locator.selector = %%-find-selector-%%
|
### param: FrameLocator.locator.selector = %%-find-selector-%%
|
||||||
* since: v1.17
|
* since: v1.17
|
||||||
|
|
|
||||||
|
|
@ -762,7 +762,7 @@ Returns locator to the last matching element.
|
||||||
* since: v1.14
|
* since: v1.14
|
||||||
- returns: <[Locator]>
|
- returns: <[Locator]>
|
||||||
|
|
||||||
The method finds an element matching the specified selector in the `Locator`'s subtree. It also accepts filter options, similar to [`method: Locator.filter`] method.
|
%%-template-locator-locator-%%
|
||||||
|
|
||||||
### param: Locator.locator.selector = %%-find-selector-%%
|
### param: Locator.locator.selector = %%-find-selector-%%
|
||||||
* since: v1.14
|
* since: v1.14
|
||||||
|
|
|
||||||
|
|
@ -1057,3 +1057,7 @@ When set to `"hide"`, screenshot will hide text caret. When set to `"initial"`,
|
||||||
- %%-screenshot-option-type-%%
|
- %%-screenshot-option-type-%%
|
||||||
- %%-screenshot-option-mask-%%
|
- %%-screenshot-option-mask-%%
|
||||||
- %%-input-timeout-%%
|
- %%-input-timeout-%%
|
||||||
|
|
||||||
|
## template-locator-locator
|
||||||
|
|
||||||
|
The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options, similar to [`method: Locator.filter`] method.
|
||||||
|
|
|
||||||
5
packages/playwright-core/types/types.d.ts
vendored
5
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -9837,7 +9837,7 @@ export interface Locator {
|
||||||
last(): Locator;
|
last(): Locator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The method finds an element matching the specified selector in the `Locator`'s subtree. It also accepts filter options,
|
* The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
|
||||||
* similar to [locator.filter([options])](https://playwright.dev/docs/api/class-locator#locator-filter) method.
|
* similar to [locator.filter([options])](https://playwright.dev/docs/api/class-locator#locator-filter) method.
|
||||||
* @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
|
* @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
|
||||||
* @param options
|
* @param options
|
||||||
|
|
@ -14738,7 +14738,8 @@ export interface FrameLocator {
|
||||||
last(): FrameLocator;
|
last(): FrameLocator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The method finds an element matching the specified selector in the FrameLocator's subtree.
|
* The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
|
||||||
|
* similar to [locator.filter([options])](https://playwright.dev/docs/api/class-locator#locator-filter) method.
|
||||||
* @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
|
* @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,14 @@ function applyTemplates(body, params) {
|
||||||
if (!template)
|
if (!template)
|
||||||
throw new Error('Bad template: ' + key);
|
throw new Error('Bad template: ' + key);
|
||||||
node.children.push(...template.children.map(c => md.clone(c)));
|
node.children.push(...template.children.map(c => md.clone(c)));
|
||||||
|
} else if (node.text && node.text.includes('%%-template-')) {
|
||||||
|
node.text.replace(/%%-template-[^%]+-%%/, templateName => {
|
||||||
|
const template = paramsMap.get(templateName);
|
||||||
|
if (!template)
|
||||||
|
throw new Error('Bad template: ' + templateName);
|
||||||
|
const nodeIndex = parent.children.indexOf(node);
|
||||||
|
parent.children = [...parent.children.slice(0, nodeIndex), ...template.children, ...parent.children.slice(nodeIndex + 1)];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
for (const child of node.children || [])
|
for (const child of node.children || [])
|
||||||
visit(child, node);
|
visit(child, node);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue