Documentations โบ mmo.client โบ js โบ core dom MMO.core.dom ยท 72 symbols ยท generated 30 Sep 2026
MMO.core.dom.BOOL_ATTRIBUTES = ['disabled', 'readonly', 'required', 'checked']; Namespace MMO.core.domMMO.core.dom.MERGEABLE_NODES = ['A', 'ABBR', 'AREA', 'AUDIO', 'B', 'BDI', 'BDO', 'BR', 'BUTTON', 'CANVAS', 'CITE', 'CODE', 'DATA', 'DATALIST', 'DEL', 'DFN', 'EM', 'EMBED', 'I', 'IFRAME', 'IMG', 'INPUT', 'INS', 'KBD', 'LABEL', 'MARK', 'MATH', 'METER', 'LINK', 'MAP', 'META', 'NOSCRIPT', 'OBJECT', 'OUTPUT', 'PICTURE', 'PROGRESS', 'Q', 'RUBY', 'S', 'SAMP', 'SCRIPT', 'SELECT', 'SLOT', 'SMALL', 'SPAN', 'STRONG', 'SUB', 'SUP', 'SVG', 'TEMPLATE', 'TEXTAREA', 'TIME', 'U', 'VAR', 'VIDEO', 'WBR']; Namespace MMO.core.domCall query selector.
function MMO.core.dom.$(node, root = null, searchParent = true) Namespace MMO.core.domRoot is used to select elements into a shadowdom node Element | stringroot = null Elementa node use as reference to get root document or shadowroot from. searchParent = true Booleanif root is defined but no element are found, search in the document returns Element | null
Call query selectorAll
function MMO.core.dom.$$(selector, root = null, searchSlot = true) Namespace MMO.core.domselector root = null Elementa node use as reference to get root document or shadowroot from. searchSlot = true Booleanif root is a shadow root, search in the slot returns Array
Make every form control inside a node read-only, or writable again.
function MMO.core.dom.readonly(node, value) Namespace MMO.core.domCheckboxes and radios have no `readonly` state of their own, so they are disabled instead. node Nodevalue booleantrue to lock, false to unlock
Create a dom element from a configuration
function MMO.core.dom.createElement(node, attrs = null, ...children) Namespace MMO.core.domnode attrs = null Array | Function | object: - an object of attributes to set ({key: value}) - a Function(element) that returns an object - an Array of the above ...children ...*MMO.core.dom.appendChildren. A string is TEXT, never markup: a file's name shows as it was typed. Markup you wrote goes through MMO.core.dom.htmlreturns Node
MMO.core.dom.createElement('li', {class: 'file'}, MMO.core.dom.createElement('mmo-icon', {name: 'file'}), file.name)
function MMO.core.dom.createElementNS(namespace, tag, attrs = null, ...children) Namespace MMO.core.domSee MMO.core.dom.createElement in an explicit xml namespace (svg, MathML, ...).namespace stringMMO.core.dom.NAMESPACE_URIStag stringattrs = null ?(Object | Function | Array)...children ...*MMO.core.dom.appendChildren: a string is textreturns Element
Create a custom event and dispatch it
function MMO.core.dom.dispatchEvent(node, name, detail = undefined, cancelable = true, bubbles = true) Namespace MMO.core.domnode Elementname stringEvent's name detail = undefined objectuser defined detail to pass to the handlers cancelable = true bubbles = true returns boolfalse if at least one handler call preventDefault
Loop through all text nodes inside a node
function* MMO.core.dom.loopTextNodes(node) Namespace MMO.core.domnode Nodethe node to use returns Generator<Text>
function MMO.core.dom.getTextNodes(node) Namespace MMO.core.domnode Nodereturns Array<Text>every text node inside, in document order
function MMO.core.dom.firstTextNode(node) Namespace MMO.core.domnode Nodereturns ?Textthe first text node inside, null when there is none
Tells if two nodes can be merged: they have the same type and the same attributes and they are part of the list MMO.core.dom.MERGEABLE_NODES or they are Text nodes
function MMO.core.dom.isMergeableNode(a, b) Namespace MMO.core.domMerge child nodes if they are mergeable
function MMO.core.dom.normalize(node) Namespace MMO.core.domCreate script
function MMO.core.dom.createScript(url, inline = false) Namespace MMO.core.domurl stringthe script url or the script text inline = false booleanif true, url should be the script text returns Scriptthe added script
Include script in html <head> or in a node
async function MMO.core.dom.includeScript(url, inline = false, parentNode = null) Namespace MMO.core.domurl stringthe script url. if it starts with ':', it is resolved with MMO.url inline = false booleanif true, url should be the script text parentNode = null returns ScriptElementthe added script
Create style
function MMO.core.dom.createStyle(url, inline = false) Namespace MMO.core.domurl stringthe style url inline = false booleanif true, url should be the style text returns stylethe added style
Include style in html <head> or in a node
function MMO.core.dom.includeStyle(url, inline = false, parentNode = null) Namespace MMO.core.domurl stringthe style url. if it starts with ':', it is resolved with MMO.url inline = false booleanif true, url should be the style text parentNode = null returns StyleElementthe added style
function MMO.core.dom.getFocusableElements(node = null) Namespace MMO.core.domThe focusable element sitting just before a node in the document's tab order.
function MMO.core.dom.getPreviousFocus(node) Namespace MMO.core.domnode Elementreturns ?Elementnull when the node is the first one, or is not focusable itself
The focusable element sitting just after a node in the document's tab order.
function MMO.core.dom.getNextFocus(node) Namespace MMO.core.domnode Elementreturns ?Elementthe LAST focusable element when the node is last, or is not focusable
Get the text position a pointer event landed on, across the three browser apis.
function MMO.core.dom.getMouseEventCaretRange(evt) Namespace MMO.core.domevt MouseEventreturns ?Rangea collapsed range, or undefined when no api is available
function MMO.core.dom.selectRange(range) Namespace MMO.core.domYield node selected in a range
function* MMO.core.dom.loopRangeNodes(range) Namespace MMO.core.domrange returns Generator<[Node node, ?number startOffset, ?number endOffset)>
function MMO.core.dom.getRangeNodes(range) Namespace MMO.core.domrange Rangereturns Array<[Node, ?number, ?number]>MMO.core.dom.loopRangeNodes
function MMO.core.dom.firstNodeInRange(range) Namespace MMO.core.domrange Rangereturns ?Nodethe first node the range touches
Check if first text element in a node is wrapped in a tag
function MMO.core.dom.isWrapped(node, tagName, attrs = null) Namespace MMO.core.domnode NodetagName stringattrs = null object | nullif specified, check all attributes are set to the given values returns boolean
Toggle wrapping text content in a selection.
function MMO.core.dom.toggleRangeTextWrapping(range, tagName, attrs = null) Namespace MMO.core.domExample toggle bold/italic/underline in a selection range tagName attrs = null object | nullif specified, apply attributes to the wrapper
Set element attributes
function MMO.core.dom.setAttributes(node, attrs) Namespace MMO.core.domnode attrs array | Function | Object- Function: function(node): value - Object: set the attributes with key,value - array: a list of the above returns void
Test if element has the given attribute's values
function MMO.core.dom.hasAttributes(node, attrs, full = false) Namespace MMO.core.domnode Elementattrs objectfull = false booleanif true, check that the node has only and all the given attributes returns boolean
Set element attribute
function MMO.core.dom.setAttribute(node, name, value) Namespace MMO.core.domnode name stringthe attribute's name value string | Function- Function: calls is with element as only argument returns void
Get element attributes as an object
function MMO.core.dom.getAttributes(node) Namespace MMO.core.domGet root HTML
function MMO.core.dom.root(node) Namespace MMO.core.domThe custom element owning the shadow root a node lives in.
function MMO.core.dom.host(node) Namespace MMO.core.domnode Nodereturns ?Elementnull when the node is not inside a shadow root
The parent element, crossing a shadow boundary to the host rather than stopping at it.
function MMO.core.dom.parentElement(node) Namespace MMO.core.domfunction MMO.core.dom.body(node) Namespace MMO.core.domnode Nodereturns HTMLElementthe body of the document the node belongs to
Test whether a node descends from another.
function MMO.core.dom.hasParent(node, parent, max = false) Namespace MMO.core.domnode Nodeparent Nodemax = false number | falsestop after this many levels returns booleanfalse when node === parent: only ancestors count
Walk up until a node carries a given tag name. The node itself is a candidate.
function MMO.core.dom.closestParent(node, tagName) Namespace MMO.core.domNOTE: this does NOT cross shadow boundaries. node NodetagName stringcase insensitive returns ?Element
Detach a node, or every node of a NodeList.
function MMO.core.dom.remove(node) Namespace MMO.core.domnode ?(Node | NodeList)returns booleanfalse when there was nothing attached to remove
Mark markup to be parsed by the functions building nodes from children (MMO.core.dom.appendChildren,
function MMO.core.dom.html(html) Namespace MMO.core.domSee MMO.core.dom.createElement, MMO.core.Template#add), which insert a plain string as text.Only for markup you wrote, or sanitized: it is parsed with `innerHTML`, so an `<img onerror>` in it runs. Never
wrap a name, a label or a message that came from a user or an api.
An array has each of its strings marked; anything else (a node, null...) is returned as it is, so a value
that may be a node or a string of markup can be handed over either way. html *returns *a MMO.core.dom.Html for a string
MMO.core.dom.createElement('p', {}, MMO.core.dom.html('<b>Saved</b> in '), folder.name)
Add children to a node using a generator
function* MMO.core.dom.loopAppendChildren(node, ...children) Namespace MMO.core.domnode Elementthe node in which to add children ...children ...*MMO.core.dom.appendChildrenreturns Generator<Node>
Add children to a node.
function MMO.core.dom.appendChildren(node, ...children) Namespace MMO.core.domA string -- or a number, or anything that is not a node -- is inserted as TEXT, never parsed: a name or a
message shows as it was typed, `<b>` included, and runs nothing. Markup goes through `MMO.core.dom.html`,
and only markup you wrote or sanitized. node Elementthe node in which to add children ...children ...*each one can be: - a Node, a NodeList, a DocumentFragment, or a <template> (its content is cloned) - MMO.core.dom.html('...'): markup, parsed - an array, or a MMO.core.Map list, of any of these - null or undefined: skipped, and so is an empty string - anything else: its text returns Array<Node>
MMO.core.dom.appendChildren(li, icon, file.name, MMO.core.dom.html(' <small>(new)</small>'))
Detach a list of nodes, flattening nested arrays and skipping null entries.
function MMO.core.dom.removeChildren(...children) Namespace MMO.core.dom...children ...(?Node | Array)
Parse html and add it to a node.
function MMO.core.dom.addHTML(node, html) Namespace MMO.core.domThe markup runs: only hand it what you wrote or sanitized. Text goes through `MMO.core.dom.appendChildren`. node Elementhtml stringreturns Array<Node>the nodes parsed, in order
Insert an Element inside a text element
function MMO.core.dom.insertNodeInText(text, node, offset, size = 0) Namespace MMO.core.domtext Textnode Element[description] offset Numberthe offset to insert the element at size = 0 Numberthe size to remove after offset (replaced by the element)
Insert a node just after another one.
function MMO.core.dom.insertAfter(node, ref) Namespace MMO.core.domnode Nodethe node to insert ref Nodethe node to insert after returns Nodethe inserted node
Get the Element from which a fixed element has his position computed. If null, it is the viewport.
function MMO.core.dom.fixedNode(node) Namespace MMO.core.domFixed element are computed from a stack context. CSS 'transform', 'filter', 'position: fixed' and 'position: sticky' create new stack context. function MMO.core.dom.getComputedStyle(node, property = null, pseudo = null) Namespace MMO.core.domnode property = null pseudo = null
Copy every COMPUTED style of a node onto another as inline styles, so the copy keeps its look once detached from the stylesheets that produced it.
function MMO.core.dom.copyStyles(nodeA, nodeB, pseudo = null) Namespace MMO.core.domnodeA Elementthe source nodeB Elementthe target pseudo = null ?stringread a pseudo element of the source instead (':before', ...)
Get the node's font-size in pixels (the value 1em resolves to).
function MMO.core.dom.getEmValue(node) Namespace MMO.core.domGet a computed style and convert it to a number (interpreting the unit)
function MMO.core.dom.getComputedStyleValue(node, property, pseudo = null) Namespace MMO.core.domnode [type][description] property [type][description] pseudo = null [type][description] returns [type][description]
Convert any css string value into a float
function MMO.core.dom.decodeUnit(node, value, em = null, percent = 1) Namespace MMO.core.domnode value *any value if string will try to read the unit and convert into a float em = null numberif value is em, will use this value as reference percent = 1 numberif value is percent, will use this value as reference returns number | stringif value is a percent value, returns a string version of the number
Make sure a value is a properly formed css value with the correct unit
function MMO.core.dom.encodeUnit(node, value = 0, unit = null, percent = 1) Namespace MMO.core.domnode value = 0 string | number[description] unit = null string | number | null('px','em','rem') unit to use by default, or another value. In that case, unit is percent percent = 1 returns string
Set css styles
function MMO.core.dom.setStyles(node, styles) Namespace MMO.core.domQueue style update in animation frame
function MMO.core.dom.setStyle(node, key, value) Namespace MMO.core.domnode Elementkey stringstyle name value *style value
Update queue styles in given node
function MMO.core.dom.updateStyles(node) Namespace MMO.core.domSet css styles
function MMO.core.dom.getStyle(node, key) Namespace MMO.core.domGet the element's absolute coordinates (left, top) using offset and scroll
function MMO.core.dom.getCoord(node, root = null) Namespace MMO.core.domnode root = null returns x: number, y: number}
Get bounding rect relative to a parent
function MMO.core.dom.getBoundingRect(node, parent = false) Namespace MMO.core.domnode parent = false Element | booleanif true, use direct parent. if false get absolute bounding rect returns x,y,width,height}
Convert an absolute document point into one relative to a node's box.
function MMO.core.dom.makeRelative(node, pt, copyPt = true) Namespace MMO.core.domnode Elementpt copyPt = true booleancarry the point's other properties over to the result returns x: number, y: number} a new object; pt is never modified
Tells if a point is inside a container
function MMO.core.dom.ptInside(node, x, y) Namespace MMO.core.domCheck if element is visible
function MMO.core.dom.isVisible(elem) Namespace MMO.core.domelem Elementreturns Boolean
Get a promise waiting for an element to become visible
function MMO.core.dom.waitUntilVisible(node, opts) Namespace MMO.core.domnode Elementto watch opts Objectthe options to pass to the IntersectionObserver returns Promise<IntersectionObserverEntry>
function MMO.core.dom.setBoundingRect(node, rect) Namespace MMO.core.domSet the current offset of the element
function MMO.core.dom.setOffset(node, x, y = null) Namespace MMO.core.domnode x y = null null | number[description] returns MMO.core.Elementthis
Move the element
function MMO.core.dom.addOffset(node, x, y) Namespace MMO.core.domSet a node's width and height, queued like every other style write.
function MMO.core.dom.setSize(node, w, h) Namespace MMO.core.domA negative value is clamped to 0, and a falsy one clears the style. node Elementw h number=the height, when w is a number
Get a unique css selector for a node It is usefull to have a visual path for a node, but it should not be used to retrieve the node. Use getPath instead.
function MMO.core.dom.getCSSPath(node, root = null) Namespace MMO.core.domnode Noderoot = null Nodethe root node to get path from. If null, use document body returns string
Get a unique path for node as indexes in childnodes WARNING: the path is reversed, so iteration starts from length-1 and not 0
function MMO.core.dom.getPath(node, root = null) Namespace MMO.core.domnode Noderoot = null Nodethe root node to get path from. If null, use document body returns stringfalse if the root node was not found
Get a node from its path
function MMO.core.dom.at(node, path) Namespace MMO.core.domnode Nodepath stringthe return value of (MMO.core.dom.getPath()) returns Node
This function allow a checkbox to cycle through 3 states: checked, unchecked, indeterminate.
function MMO.core.dom.onIndeterminateClick(event) Namespace MMO.core.domIt is meant to be used in the onclick attribute: `<input type="checkbox" onclick="MMO.core.dom.onIndeterminateClick(event)" />`