Gets the child nodes wrapped in the most specific JJ wrappers available.
The wrapped child nodes.
Gets the parent node wrapped in the most specific JJ wrapper available.
The wrapped parent node, or null if this node has no parent.
Creates a Text node from a string and appends it to this Node.
The text to add. The actual text that's added follows the rules in document.createTextNode() which is basically what you get from String()
This instance for chaining.
el.addText('Hello ')
el.addText('World')
// Behaves like document.createTextNode('Hello World') and appends it to el
// Falsy values are converted to their string representation, except for empty string which is added as is.
el.addText('Hello', '', 'world', null, undefined, '!!!') // Adds 6 text nodes with content 'Hello', '', 'world', 'null', 'undefined', and '!!!' respectively.
Removes an event listener.
The name of the event.
The event handler.
Optionaloptions: boolean | EventListenerOptionsOptional event listener options or boolean.
This instance for chaining.
Adds an event listener.
The name of the event.
The event handler.
Optionaloptions: AddEventListenerOptionsOptional event listener options.
This instance for chaining.
Removes this node from its parent.
This instance for chaining.
Runs a function in the context of this JJET instance.
The synchronous function to run. this inside the function will refer to this JJET instance, and the wrapped instance is also passed as the first argument.
This instance for chaining.
node
.run(function (context) {
console.log(this.ref)
console.log(context.ref)
})
.trigger(new Event('ready'))
Dispatches an Event at the specified EventTarget.
The Event object to dispatch.
This instance for chaining.
Creates and dispatches a CustomEvent on the wrapped target.
This instance for chaining.
This is a convenience wrapper around trigger for the common case of dispatching a payload-bearing custom event.
The created event defaults to bubbles: true and composed: true.
Pass options to override those defaults.
StaticfromCreates a JJN instance from a Node reference.
The Node instance.
A new JJN instance.
StaticisChecks if a value can be passed to the wrap() or unwrap() function.
an unknown value
true if x is a string, Node (or its descendent), JJN (or its descendent)
This is useful for filtering the array that is passed to append(), prepend() or setChildren().
See Wrappable type for the full definition.
StaticunwrapExtracts the underlying native DOM node from a wrapper.
The value to unwrap.
The underlying DOM node.
If the input is already a native Node, it is returned as is.
If the input is a JJ wrapper, its underlying node is returned.
Otherwise, the input is coerced into a Text node.
Plain objects are stringified with JSON when possible, and fall back to String(...).
StaticunwrapUnwraps an iterable object (e.g. an array or HTMLCollection).
The iterable to unwrap.
An array of native DOM nodes.
StaticwrapWraps a native DOM node or string into the most specific JJ wrapper available.
The object to wrap. If it's already Wrapped, it'll be returned without any change. We don't double-wrap or clone it.
The most granular Wrapped subclass instance. If the input is already wrapped, it'll be returned as is without cloning.
This factory function acts as an intelligent wrapper, inspecting the input type and returning the appropriate
subclass of JJN (e.g., JJHE for HTMLElement, JJT for Text, JJSE for SVGElement, etc.).
Strings are automatically converted to Text nodes wrapped in JJT.
If the input is already a JJ wrapper, it is returned unchanged (no double-wrapping). See the full implementation in src/wrappers/JJN.ts which extends this with support for internal wrapper types.
const bodyWrapper = JJN.wrap(document.body) // Returns JJHE<HTMLBodyElement>
const textWrapper = JJN.wrap('Hello') // Returns JJT wrapping a new Text node
const existing = JJN.wrap(alreadyWrapped) // Returns alreadyWrapped unchanged
StaticwrapWraps an iterable object (e.g. an array of wrapped or DOM elements).
The iterable to wrap.
An array of wrapped instances.
Wraps a DOM Node.
Remarks
This is the base class for all JJ wrappers. It provides common functionality for DOM manipulation, traversal, and event handling.
See
Node