Skip to content

Commit 488951a

Browse files
committed
docs: Improved description
1 parent 07e22df commit 488951a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/index.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ const sources = new Map()
3232
const renderedNodes = new Map()
3333
const elementSelector = '[render-selector], [render-closest], [render-parent], [render-next], [render-previous]'
3434

35+
36+
/**
37+
* Initializes elements based on specified rendering attributes. If a specific element is provided, it initializes that element.
38+
* If no element is provided, it queries and initializes all elements matching the defined selector criteria for rendering attributes.
39+
*
40+
* Supported rendering attributes:
41+
* - render-selector: [Describe what this attribute does]
42+
* - render-closest: [Describe what this attribute does]
43+
* - render-parent: [Describe what this attribute does]
44+
* - render-next: [Describe what this attribute does]
45+
* - render-previous: [Describe what this attribute does]
46+
*
47+
* @param {(Element|Element[]|HTMLCollection|null)} [element] - Optional. A single element, an array of elements, an HTMLCollection, or null.
48+
* - If an HTMLCollection or an array of elements is provided, each element in the collection/array is initialized.
49+
* - If a single element is provided, only that element is initialized.
50+
* - If null or omitted, the function queries and initializes all elements matching the 'elementSelector'.
51+
*/
3552
function init(element) {
3653
if (element && !(element instanceof HTMLCollection) && !Array.isArray(element))
3754
element = [element]
@@ -48,6 +65,21 @@ function init(element) {
4865
}
4966
}
5067

68+
/**
69+
* Asynchronously renders content based on the provided parameters. This function handles the rendering logic for elements
70+
* based on data sources, selectors, and other options.
71+
*
72+
* @param {Object} options - An object containing the parameters for rendering.
73+
* @param {Object} options.source - The data source used for rendering.
74+
* @param {Element} options.element - The DOM element where content will be rendered.
75+
* @param {string} options.selector - CSS selector to specify target elements for rendering.
76+
* @param {Object} options.data - Data to be used in rendering.
77+
* @param {string} [options.key] - Optional key to reference specific parts of the data.
78+
* @param {number} [options.index] - Optional index, typically used when rendering lists or arrays.
79+
* @param {number} [options.currentIndex] - The current index in a list or array rendering process.
80+
* @param {boolean} [options.update] - Flag to indicate if the rendering should update existing content.
81+
* @param {boolean} [options.remove] - Flag to indicate if the rendering should remove elements instead of updating or appending.
82+
*/
5183
async function render({ source, element, selector, data, key, index, currentIndex, update, remove }) {
5284
if (!element) {
5385
if (source) {

0 commit comments

Comments
 (0)