Type alias for ElementCSSInlineStyle
(objects with a style property of type
CSSStyleDeclaration
,
most commonly elements)
Returns a promise that resolves as soon as possible after the DOM content is loaded.
If the document.readyState
is 'interactive'
or 'complete'
at call-time, the returned promise resolves immediately, otherwise it resolves upon
the DOMContentLoaded event.
Curried function that first takes a list of classes, then returns a new function that takes the element to add those classes to.
Rest parameter for one or multiple classes to add.
The element to add the classes to.
Adds classes to an element for a given amount of milliseconds.
The amount of milliseconds to add the classes for
Rest parameter for one or multiple classes to temporarily add
The element to add the classes to
Adds classes to an element for a given amount of animation frames.
The amount of animation frames to add the classes for.
Rest parameter for one or multiple classes to temporarily add.
The element to add the classes to.
Takes a positive (>= 0) integer n
and a callback function, and executes the callback function after n
animation frames have passed.
The amount of animation frames to wait.
The callback function to run after n
animation-frames have passed.
Returns a Promise<void>
that resolves after n
animation frames have passed.
Like deferFrames
but 'portable', so that many callbacks can subscribe
to the 'event' of n
frames having passed.
The amount of animation frames to wait before the returned promise resolves.
Takes a CSS display value and returns a function that takes
elements. When applied to an element the returned function
assigns the given display value to the given element's style.display
property.
The display CSS value to use. When null
any inline display value is removed.
The target element to set the display value on.
Takes a boolean
condition and a CSS display value, and returns a function
that takes elements. The returned function will set style.display
onto given elements to either given
value or to 'none'
based on the given cond
boolean.
Note that the condition is constant for all future calls to the returned function. See displayUsing() for cases where the boolean condition should be determined for each element individually.
The condition for showing elements
The style.display
value to use
Takes a predicate function for elements and a CSS display value, and returns
a function that takes elements. The returned function will set style.display
onto given elements to either
given value or to 'none'
based on the result of applying the predicate to those elements.
Get the value of the content attribute for the first (and presumably only)
<meta>
element with given name
as the value for its name attribute.
Optionally takes a transformer to deserialize string values.
The value for the name
attribute to find the <meta>
element by.
Get the value of the content attribute for the first (and presumably only)
<meta>
element with given name
as the value for its name attribute.
Optionally takes a transformer to deserialize string values.
The value for the name
attribute to find the <meta>
element by.
A transformer function that deserializes content values.
Hide the given element through the style.display property.
This is a specialisation of display() that always sets display to 'none'
.
The element to hide.
Takes an HTML string or null
, and returns a function that takes Element
objects. Sets innerHTML
of
given elements to the given string, or to an empty string if given null
.
Takes a string or null
, and returns a function that takes HTMLElement
elements. Sets innerText
of
given elements to the given string, or to an empty string if given null
.
Takes a callback that is executed as soon as possible after the DOM content is loaded.
If the document.readyState
is either 'interactive'
or 'complete'
at call-time, the callback is called immediately,
otherwise it is called upon the DOMContentLoaded event.
A promise that resolves with the eventual return value of given callback.
Takes a callback that is executed as soon as possible after the window is loaded.
If the document.readyState
is 'complete'
at call-time, the callback is called immediately, otherwise it is called upon
the window load event.
A promise that resolves with the eventual return value of given callback.
Takes events and calls their .preventDefault()
method.
The event instance to call the method on.
Calls querySelectorAll
with given selector
on given scope
, or on document
by default when the
scope is omitted. Returns an array containing the found elements. Attempts to parse the given CSS selector
to determine the element type.
The selector to match elements against.
The scope of the element query. When omitted queryAll
performs a global search.
Takes an element as scope for CSS selector queries. Returns a function that takes selectors to query elements for within the set scope. The returned function finds all elements matching given selector and returns them in an array.
Calls querySelector
with given selector
on given scope
, or on document
by default when the
scope is omitted. Returns the first element matching given selector if any exists, or null
otherwise.
Attempts to parse the given CSS selector to determine the element type.
The selector to match elements against.
The scope of the element query. When omitted queryOne
performs a global search.
Takes an element as scope for CSS selector queries. Returns a function that takes
selectors to query elements for within the set scope. The returned function finds
the first element matching given selector and returns it. Returns null
if no
matching element exists.
Read dataset values. Takes a dataset key and optionally a transformer for the corresponding value, and returns a new function that takes the element to read the dataset key from.
The dataset key to read (camelCase, like the native dataset API).
The element to read the dataset value from.
Read dataset values. Takes a dataset key and optionally a transformer for the corresponding value, and returns a new function that takes the element to read the dataset key from.
The dataset key to read (camelCase, like the native dataset API).
The optional transformer function for dataset values.
The element to read the dataset value from.
Removes given element from the DOM if it's currently in it.
Curried function that first takes a list of classes, then returns a new function that takes the element to remove those classes from.
Rest parameter for one or multiple classes to remove.
The element to remove the classes from.
Removes classes from an element for a given amount of milliseconds.
The amount of milliseconds to remove the classes for.
Rest parameter for one or multiple classes to remove.
The element to remove the classes from.
Removes classes from an element for a given amount of animation frames.
The amount of animation frames to remove the classes for.
Rest parameter for one or multiple classes to temporarily remove.
The element to remove the classes from.
Takes a string name and returns a new function that takes a string content, and
then updates the <meta>
tag with the given name if it exists, or otherwise
creates a new one. The meta element to which the content value was set is returned
for reference.
When a new element is created it will be appended to the end of <head>
.
The value for the name attribute.
The value for the content attribute.
Shows the given element by unsetting any inline style.display
value.
This is a specialisation of display() that always unsets inline display.
Note
This function assumes that given elements are shown by default - ie. there's no CSS rule that has set the element's display to 'none'.
The element to unset the inline display value for.
Takes a boolean
condition, and returns a function that takes elements. The returned function
will unset style.display
onto a given element if the given condition is true
. If the condition
is false
, style.display
is set to 'none'
.
Note
This function assumes that given elements are shown by default - ie. there's no CSS rule that has set the element's display to 'none'.
Note
The condition is constant for all future calls to the returned function. See showUsing() for cases where the boolean condition should be determined for each element individually.
The condition for showing elements
Takes a predicate function for elements and returns a function that takes elements to conditionally show depending on the result of applying the predicate function to given elements.
Note
This function assumes that given elements are shown by default - ie. there's no CSS rule that has set the element's display to 'none'.
Takes an object of style attribute values, and returns a new function that takes an element to apply those styles to.
An object with inline styles to set.
An element to apply the inline styles to.
Curried function that first takes a list of classes, then returns a new function that
takes the element on which to toggle those classes. The second function optionally takes
the second argument force: boolean
to use on the native DOMTokenList.toggle()
method.
Note that the value for force
will be the same for all classes that are toggled.
One or multiple classes to toggle.
An element onto which to toggle provided classes.
The optional boolean for force adding / removing the classes (like the native DOMTokenList.toggle
)
Takes an array of CSS-style element selectors and a callback function. When for all selectors an element is found, the callback is called with each found element in order. Optionally takes a scope as third argument to use for the element search.
Note: touchAll
has overloads for tuples of up to 8 selectors.
An array of CSS-style selectors. For each selector an element will be searched.
The callback to execute when all elements are found.
An optional scope for the element queries.
Takes an array of CSS-style selectors. Returns a promise that will only resolve when for all selectors an element is found. The promise value is an array of the elements in the order of the selector array. Optionally takes a scope as third argument to use for the element search.
Note: touchAllP
has overloads for tuples of up to 8 selectors.
Like touchAll
but 'portable', so that many callbacks can subscribe
to the 'event' of the elements being found.
An array of CSS-style selectors. For each selector an element will be searched.
An optional scope for the element queries.
Finds the first element within the set scope that matches selector
. If found the element
is applied to the given callback function, and the function's return value will be propagated
as return value of touchElement
. If no element is found, the callback is not invoked, and
null
is returned from touchElement
.
A CSS-compatible selector to match the searched element against.
The callback to execute when the element is found.
An optional scope for the element query.
Finds the first element within the set scope that matches selector
. If found the returned
promise resolves with the element. If no element is found, the promise will never resolve.
Like touchElement
but 'portable', so that many callbacks can subscribe
to the 'event' of the element being found.
A CSS-compatible selector to match the searched element against.
An optional scope for the element query.
Returns a promise that resolves as soon as possible after the window is loaded.
If the document.readyState
is 'complete'
at call-time, the returned promise resolves immediately, otherwise it resolves upon
the window load event.
Write dataset values. Takes a key, and returns a new function that takes the value, which in turn returns the last function that takes the element to write the key-value pair to.
The dataset property to write.
The value to write to the property.
An element upon which to perform the dataset update.
Generated using TypeDoc
Autocomplete list for the most commonly used
style.display
values. Includes the genericstring
type for compatibility and special syntax, as well asnull | undefined
which are used by lambda-dom as a signal to unset inline display values.