Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve docs to more clearly link to the options interface for queryAssignedNodes #2360

Merged
merged 4 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/brave-planes-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lit/reactive-element': patch
---

Update `@queryAssignedNodes` and `@queryAssignedElements` documentation for better lit.dev API generation.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ import {decorateProperty} from './base.js';
import type {ReactiveElement} from '../reactive-element.js';
import type {QueryAssignedNodesOptions} from './query-assigned-nodes.js';

/**
* Options for the [[`queryAssignedElements`]] decorator. Extends the options
* that can be passed into
* [HTMLSlotElement.assignedElements](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedElements).
*/
export interface QueryAssignedElementsOptions
extends QueryAssignedNodesOptions {
/**
* CSS selector used to filter the elements returned.
* CSS selector used to filter the elements returned. For example, a selector
* of `".item"` will only include elements with the `item` class.
*/
selector?: string;
}
Expand All @@ -30,6 +36,8 @@ export interface QueryAssignedElementsOptions
* way to use
* [`slot.assignedElements`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedElements).
*
* Can be passed an optional [[`QueryAssignedElementsOptions`]] object.
*
* Example usage:
* ```ts
* class MyElement {
Expand All @@ -49,15 +57,6 @@ export interface QueryAssignedElementsOptions
*
* Note, the type of this property should be annotated as `Array<HTMLElement>`.
*
* @param options Object that sets options for nodes to be returned. See
* [MDN parameters section](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedElements#parameters)
* for available options. Also accepts two more optional properties,
* `slot` and `selector`.
* @param options.slot Name of the slot. Undefined or empty string for the
* default slot.
* @param options.selector Element results are filtered such that they match the
* given CSS selector.
*
* @category Decorator
*/
export function queryAssignedElements(options?: QueryAssignedElementsOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ import {decorateProperty} from './base.js';

import type {ReactiveElement} from '../reactive-element.js';

/**
* Options for the [[`queryAssignedNodes`]] decorator. Extends the options that
* can be passed into
* [HTMLSlotElement.assignedNodes](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedNodes).
*/
export interface QueryAssignedNodesOptions extends AssignedNodesOptions {
/**
* Name of the slot. Leave empty for the default slot.
* Name of the slot to query. Leave empty for the default slot.
*/
slot?: string;
}
Expand All @@ -30,6 +35,8 @@ type TSDecoratorReturnType = void | any;
* A property decorator that converts a class property into a getter that
* returns the `assignedNodes` of the given `slot`.
*
* Can be passed an optional [[`QueryAssignedNodesOptions`]] object.
*
* Example usage:
* ```ts
* class MyElement {
Expand All @@ -46,12 +53,6 @@ type TSDecoratorReturnType = void | any;
*
* Note the type of this property should be annotated as `Array<Node>`.
*
* @param options Object that sets options for nodes to be returned. See
* [MDN parameters section](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedNodes#parameters)
* for available options.
* @param options.slot Name of the slot. Undefined or empty string for the
* default slot.
*
* @category Decorator
*/
export function queryAssignedNodes(
Expand Down