getBindData
Overview
Section titled “Overview”The getBindData
function is used to retrieve or create a BindData object associated with a DOM node. The BindData object contains information about bound data and associated unbinders for Regor.
Retrieving or Creating BindData
Section titled “Retrieving or Creating BindData”To retrieve the BindData associated with a DOM node, call the getBindData
function with the DOM node as the parameter. If a BindData object is already associated with the node, it will be returned. If not, a new BindData object will be created and associated with the node.
Example
Section titled “Example”import { getBindData } from 'regor'
// Retrieve or create BindData for a DOM nodeconst someElement = document.getElementById('example')const bindData = getBindData(someElement)
// Access the BindData propertiesconsole.log(bindData.data) // Access bound dataconsole.log(bindData.unbinders) // Access associated unbinders
Parameters
Section titled “Parameters”node
: The DOM node for which you want to retrieve or create the associated BindData object.
Return Value
Section titled “Return Value”The getBindData
function returns a BindData
object associated with the provided DOM node. This object contains the following properties:
-
unbinders
: An array of unbinders that can be used to remove bound data and associated logic from the DOM node. -
data
: A record of bound data, where keys represent data properties, and values represent the associated data.
-
The
getBindData
function is typically used internally within Regor to manage bound data and unbinders associated with DOM nodes. -
It provides a way to access and manipulate the bound data and unbinders for a specific DOM element.
-
BindData objects are created and associated with DOM nodes as needed when data is bound to elements using Regor.
-
The
unbind
function can be used to remove bound data and associated unbinders from a DOM node, effectively cleaning up any Regor-related bindings. -
This function is primarily intended for use in advanced scenarios where direct access to Regor’s internal data management is required.