Creates an instance of JJT.
The Text node or a string to create a Text node from.
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.
Appends text to the existing content.
The string to add to the existing contents. If null or undefined, nothing is added.
This instance for chaining.
Clears the text content of the Text node.
This instance for chaining.
Gets the text content of the Text node.
The text content.
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'))
Sets the text content of the Text node.
Optionaltext: unknownThe text to set. Set it to null or undefined to remove all text
This instance for chaining.
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.
StaticcreateCreates a JJT instance from a string.
The string to convert into a Text node.
A new JJT instance wrapping a Text node.
StaticfromCreates a JJT instance from a Text node.
The Text node.
A new JJT instance.
Use JJT.create to create a Text node from a string. For other Node types, use JJN.from or the specific wrapper type.
JJT.create for creating from string input.
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 Text Node.
Remarks
The Text interface represents the textual content of Element or Attr. If an element has no markup within its content, it has a single child implementing Text that contains the element's text.
See
Text