[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> dom.js (summary)

References: Focusable: - https://www.w3.org/TR/html5/editing.html#focus-management

File Size: 2016 lines (62 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 60 functions

  buildSelector()
  isVisible()
  isValidFocusableArea()
  find()
  getTabIndex()
  isTabbableIndex()
  createStatefulCollapseRadioGroup()
  mapElementToObjectTabbable()
  mapObjectTabbableToElement()
  compareObjectTabbables()
  filterTabbable()
  tabbable_find()
  findPrevious()
  findNext()
  assertIsDefined()
  getRectangleFromRange()
  computeCaretRect()
  documentHasTextSelection()
  isHTMLInputElement()
  isTextField()
  inputFieldHasUncollapsedSelection()
  documentHasUncollapsedSelection()
  documentHasSelection()
  getComputedStyle()
  getScrollContainer()
  getOffsetParent()
  isInputOrTextArea()
  isEntirelySelected()
  isDeepChild()
  isFormElement()
  isRTL()
  getRangeHeight()
  isSelectionForward()
  caretRangeFromPoint()
  hiddenCaretRangeFromPoint()
  scrollIfNoRange()
  isEdge()
  isHorizontalEdge()
  isNumberInput()
  isVerticalEdge()
  getRange()
  placeCaretAtEdge()
  placeCaretAtHorizontalEdge()
  placeCaretAtVerticalEdge()
  insertAfter()
  remove()
  replace()
  unwrap()
  replaceTag()
  wrap()
  safeHTML()
  stripHTML()
  isEmpty()
  getPhrasingContentSchema()
  isPhrasingContent()
  isTextContent()
  isElement()
  cleanNodeList()
  removeInvalidHTML()
  getFilesFromDataTransfer()

Functions
Functions that are not part of a class:

buildSelector(sequential)   X-Ref
Returns a CSS selector used to query for focusable elements.

return: {string} CSS selector.
param: {boolean} sequential If set, only query elements that are sequentially

isVisible(element)   X-Ref
Returns true if the specified element is visible (i.e. neither display: none
nor visibility: hidden).

return: {boolean} Whether element is visible.
param: {HTMLElement} element DOM element to test.

isValidFocusableArea(element)   X-Ref
Returns true if the specified area element is a valid focusable element, or
false otherwise. Area is only focusable if within a map where a named map
referenced by an image somewhere in the document.

return: {boolean} Whether area element is valid for focus.
param: {HTMLAreaElement} element DOM area element to test.

find(context, {sequential = false} = {})   X-Ref
Returns all focusable elements within a given context.

return: {HTMLElement[]} Focusable elements.
param: {Element} context              Element in which to search.
param: {Object}  options
param: {boolean} [options.sequential] If set, only return elements that are

getTabIndex(element)   X-Ref
Returns the tab index of the given element. In contrast with the tabIndex
property, this normalizes the default (0) to avoid browser inconsistencies,
operating under the assumption that this function is only ever called with a
focusable node.

return: {number} Tab index of element (default 0).
param: {Element} element Element from which to retrieve.

isTabbableIndex(element)   X-Ref
Returns true if the specified element is tabbable, or false otherwise.

return: {boolean} Whether element is tabbable.
param: {Element} element Element to test.

createStatefulCollapseRadioGroup()   X-Ref
Returns a stateful reducer function which constructs a filtered array of
tabbable elements, where at most one radio input is selected for a given
name, giving priority to checked input, falling back to the first
encountered.

return: {(acc: MaybeHTMLInputElement[], el: MaybeHTMLInputElement) => MaybeHTMLInputElement[]} Radio group collapse reducer.

mapElementToObjectTabbable(element, index)   X-Ref
An array map callback, returning an object with the element value and its
array index location as properties. This is used to emulate a proper stable
sort where equal tabIndex should be left in order of their occurrence in the
document.

return: {{ element: HTMLElement, index: number }} Mapped object with element, index.
param: {HTMLElement} element Element.
param: {number}      index   Array index of element.

mapObjectTabbableToElement(object)   X-Ref
An array map callback, returning an element of the given mapped object's
element value.

return: {HTMLElement} Mapped object element.
param: {{ element: HTMLElement }} object Mapped object with element.

compareObjectTabbables(a, b)   X-Ref
A sort comparator function used in comparing two objects of mapped elements.

return: {number} Comparator result.
param: {{ element: HTMLElement, index: number }} a First object to compare.
param: {{ element: HTMLElement, index: number }} b Second object to compare.

filterTabbable(focusables)   X-Ref
Givin focusable elements, filters out tabbable element.

return: {HTMLElement[]} Tabbable elements.
param: {HTMLElement[]} focusables Focusable elements to filter.

tabbable_find(context)   X-Ref

return: {HTMLElement[]} Tabbable elements within the context.
param: {Element} context

findPrevious(element)   X-Ref
Given a focusable element, find the preceding tabbable element.

return: {HTMLElement|undefined} Preceding tabbable element.
param: {Element} element The focusable element before which to look. Defaults

findNext(element)   X-Ref
Given a focusable element, find the next tabbable element.

return: {HTMLElement|undefined} Next tabbable element.
param: {Element} element The focusable element after which to look. Defaults

assertIsDefined(val, name)   X-Ref
No description

getRectangleFromRange(range)   X-Ref
Get the rectangle of a given Range. Returns `null` if no suitable rectangle
can be found.

return: {DOMRect?} The rectangle.
param: {Range} range The range.

computeCaretRect(win)   X-Ref
Get the rectangle for the selection in a container.

return: {DOMRect | null} The rectangle.
param: {Window} win The window of the selection.

documentHasTextSelection(doc)   X-Ref
Check whether the current document has selected text. This applies to ranges
of text in the document, and not selection inside `<input>` and `<textarea>`
elements.

See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.

return: {boolean} True if there is selection, false if not.
param: {Document} doc The document to check.

isHTMLInputElement(node)   X-Ref

return: {node is HTMLInputElement} Whether the node is an HTMLInputElement.
param: {Node} node

isTextField(node)   X-Ref
Check whether the given element is a text field, where text field is defined
by the ability to select within the input, or that it is contenteditable.

See: https://html.spec.whatwg.org/#textFieldSelection

return: {node is HTMLElement} True if the element is an text field, false if not.
param: {Node} node The HTML element.

inputFieldHasUncollapsedSelection(element)   X-Ref
Check whether the given input field or textarea contains a (uncollapsed)
selection of text.

CAVEAT: Only specific text-based HTML inputs support the selection APIs
needed to determine whether they have a collapsed or uncollapsed selection.
This function defaults to returning `true` when the selection cannot be
inspected, such as with `<input type="time">`. The rationale is that this
should cause the block editor to defer to the browser's native selection
handling (e.g. copying and pasting), thereby reducing friction for the user.

See: https://html.spec.whatwg.org/multipage/input.html#do-not-apply

return: {boolean} Whether the input/textareaa element has some "selection".
param: {Element} element The HTML element.

documentHasUncollapsedSelection(doc)   X-Ref
Check whether the current document has any sort of (uncollapsed) selection.
This includes ranges of text across elements and any selection inside
textual `<input>` and `<textarea>` elements.

return: {boolean} Whether there is any recognizable text selection in the document.
param: {Document} doc The document to check.

documentHasSelection(doc)   X-Ref
Check whether the current document has a selection. This includes focus in
input fields, textareas, and general rich-text selection.

return: {boolean} True if there is selection, false if not.
param: {Document} doc The document to check.

getComputedStyle(element)   X-Ref

return: {ReturnType<Window['getComputedStyle']>} The computed style for the element.
param: {Element} element

getScrollContainer(node, direction = 'vertical')   X-Ref
Given a DOM node, finds the closest scrollable container node or the node
itself, if scrollable.

return: {Element | undefined} Scrollable container node, if found.
param: {Element | null} node      Node from which to start.
param: {?string}        direction Direction of scrollable container to search for ('vertical', 'horizontal', 'all').

getOffsetParent(node)   X-Ref
Returns the closest positioned element, or null under any of the conditions
of the offsetParent specification. Unlike offsetParent, this function is not
limited to HTMLElement and accepts any Node (e.g. Node.TEXT_NODE).

return: {Node | null} Offset parent.
param: {Node} node Node from which to find offset parent.

isInputOrTextArea(element)   X-Ref

return: {element is HTMLInputElement | HTMLTextAreaElement} Whether the element is an input or textarea
param: {Element} element

isEntirelySelected(element)   X-Ref
Check whether the contents of the element have been entirely selected.
Returns true if there is no possibility of selection.

return: {boolean} True if entirely selected, false if not.
param: {HTMLElement} element The element to check.

isDeepChild(query, container, propName)   X-Ref
Check whether the contents of the element have been entirely selected.
Returns true if there is no possibility of selection.

return: {boolean} True if query is a deep first/last child of container, false otherwise.
param: {HTMLElement|Node}         query     The element to check.
param: {HTMLElement}              container The container that we suspect "query" may be a first or last child of.
param: {"firstChild"|"lastChild"} propName  "firstChild" or "lastChild"

isFormElement(element)   X-Ref
Detects if element is a form element.

return: {boolean} True if form element and false otherwise.
param: {Element} element The element to check.

isRTL(element)   X-Ref
Whether the element's text direction is right-to-left.

return: {boolean} True if rtl, false if ltr.
param: {Element} element The element to check.

getRangeHeight(range)   X-Ref
Gets the height of the range without ignoring zero width rectangles, which
some browsers ignore when creating a union.

return: {number | undefined} Height of the range or undefined if the range has no client rectangles.
param: {Range} range The range to check.

isSelectionForward(selection)   X-Ref
Returns true if the given selection object is in the forward direction, or
false otherwise.

return: {boolean} Whether the selection is forward.
param: {Selection} selection Selection object to check.

caretRangeFromPoint(doc, x, y)   X-Ref
Polyfill.
Get a collapsed range for a given point.

return: {Range | null} The best range for the given point.
param: {DocumentMaybeWithCaretPositionFromPoint} doc The document of the range.
param: {number}                                  x   Horizontal position within the current viewport.
param: {number}                                  y   Vertical position within the current viewport.

hiddenCaretRangeFromPoint(doc, x, y, container)   X-Ref
Get a collapsed range for a given point.
Gives the container a temporary high z-index (above any UI).
This is preferred over getting the UI nodes and set styles there.

return: {?Range} The best range for the given point.
param: {Document}    doc       The document of the range.
param: {number}      x         Horizontal position within the current viewport.
param: {number}      y         Vertical position within the current viewport.
param: {HTMLElement} container Container in which the range is expected to be found.

scrollIfNoRange(container, alignToTop, callback)   X-Ref
If no range range can be created or it is outside the container, the element
may be out of view, so scroll it into view and try again.

return: {?Range} The range returned by the callback.
param: {HTMLElement} container  The container to scroll.
param: {boolean}     alignToTop True to align to top, false to bottom.
param: {Function}    callback   The callback to create the range.

isEdge(container, isReverse, onlyVertical = false)   X-Ref
Check whether the selection is at the edge of the container. Checks for
horizontal position by default. Set `onlyVertical` to true to check only
vertically.

return: {boolean} True if at the edge, false if not.
param: {HTMLElement} container            Focusable element.
param: {boolean}     isReverse            Set to true to check left, false to check right.
param: {boolean}     [onlyVertical=false] Set to true to check only vertical position.

isHorizontalEdge(container, isReverse)   X-Ref
Check whether the selection is horizontally at the edge of the container.

return: {boolean} True if at the horizontal edge, false if not.
param: {HTMLElement} container Focusable element.
param: {boolean}     isReverse Set to true to check left, false for right.

isNumberInput(node)   X-Ref
Check whether the given element is an input field of type number.

return: {node is HTMLInputElement} True if the node is number input.
param: {Node} node The HTML node.

isVerticalEdge(container, isReverse)   X-Ref
Check whether the selection is vertically at the edge of the container.

return: {boolean} True if at the vertical edge, false if not.
param: {HTMLElement} container Focusable element.
param: {boolean}     isReverse Set to true to check top, false for bottom.

getRange(container, isReverse, x)   X-Ref
Gets the range to place.

return: {Range|null} The range to place.
param: {HTMLElement}      container Focusable element.
param: {boolean}          isReverse True for end, false for start.
param: {number|undefined} x         X coordinate to vertically position.

placeCaretAtEdge(container, isReverse, x)   X-Ref
Places the caret at start or end of a given element.

param: {HTMLElement}      container Focusable element.
param: {boolean}          isReverse True for end, false for start.
param: {number|undefined} x         X coordinate to vertically position.

placeCaretAtHorizontalEdge(container, isReverse)   X-Ref
Places the caret at start or end of a given element.

param: {HTMLElement} container Focusable element.
param: {boolean}     isReverse True for end, false for start.

placeCaretAtVerticalEdge(container, isReverse, rect)   X-Ref
Places the caret at the top or bottom of a given element.

param: {HTMLElement} container Focusable element.
param: {boolean}     isReverse True for bottom, false for top.
param: {DOMRect}     [rect]    The rectangle to position the caret with.

insertAfter(newNode, referenceNode)   X-Ref
Given two DOM nodes, inserts the former in the DOM as the next sibling of
the latter.

return: {void}
param: {Node} newNode       Node to be inserted.
param: {Node} referenceNode Node after which to perform the insertion.

remove(node)   X-Ref
Given a DOM node, removes it from the DOM.

return: {void}
param: {Node} node Node to be removed.

replace(processedNode, newNode)   X-Ref
Given two DOM nodes, replaces the former with the latter in the DOM.

return: {void}
param: {Element} processedNode Node to be removed.
param: {Element} newNode       Node to be inserted in its place.

unwrap(node)   X-Ref
Unwrap the given node. This means any child nodes are moved to the parent.

return: {void}
param: {Node} node The node to unwrap.

replaceTag(node, tagName)   X-Ref
Replaces the given node with a new node with the given tag name.

return: {Element} The new node.
param: {Element} node    The node to replace
param: {string}  tagName The new tag name.

wrap(newNode, referenceNode)   X-Ref
Wraps the given node with a new node with the given tag name.

param: {Element} newNode       The node to insert.
param: {Element} referenceNode The node to wrap.

safeHTML(html)   X-Ref
Strips scripts and on* attributes from HTML.

return: {string} The sanitized HTML.
param: {string} html HTML to sanitize.

stripHTML(html)   X-Ref
Removes any HTML tags from the provided string.

return: {string} The text content with any html removed.
param: {string} html The string containing html.

isEmpty(element)   X-Ref
Recursively checks if an element is empty. An element is not empty if it
contains text or contains elements with attributes such as images.

return: {boolean} Whether or not the element is empty.
param: {Element} element The element to check.

getPhrasingContentSchema(context)   X-Ref
Get schema of possible paths for phrasing content.

return: {Partial<ContentSchema>} Schema.
param: {string} [context] Set to "paste" to exclude invisible elements and

isPhrasingContent(node)   X-Ref
Find out whether or not the given node is phrasing content.

return: {boolean} True if phrasing content, false if not.
param: {Node} node The node to test.

isTextContent(node)   X-Ref

return: {boolean} Node is text content
param: {Node} node

isElement(node)   X-Ref

return: {node is Element} True if node is an Element node
param: {Node | null | undefined} node

cleanNodeList(nodeList, doc, schema, inline)   X-Ref
Given a schema, unwraps or removes nodes, attributes and classes on a node
list.

param: {NodeList} nodeList The nodeList to filter.
param: {Document} doc      The document of the nodeList.
param: {Schema}   schema   An array of functions that can mutate with the provided node.
param: {boolean}  inline   Whether to clean for inline mode.

removeInvalidHTML(HTML, schema, inline)   X-Ref
Given a schema, unwraps or removes nodes, attributes and classes on HTML.

return: {string} The cleaned up HTML.
param: {string}                             HTML   The HTML to clean up.
param: {import('./clean-node-list').Schema} schema Schema for the HTML.
param: {boolean}                            inline Whether to clean for inline mode.

getFilesFromDataTransfer(dataTransfer)   X-Ref
Gets all files from a DataTransfer object.

return: {File[]} An array containing all files.
param: {DataTransfer} dataTransfer DataTransfer object to inspect.



Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref