shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
whenAttribute
Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.dom.when
Resolve a promise when the wanted attribute on the passed HTMLElement exist or pass the check function provided
Params
- $elm*-HTMLElement
The HTMLElement on which to monitor the property
- attribute*-String
The attribute to monitor
- checkFnnullFunction
Optional function to check the attribute. The promise is resolved when this function return true
Return
- -(Promise)
The promise that will be resolved when the attribute exist on the element (and that it passes the checkFn)
Example
import { whenAttribute } from '@blackbyte/sugar/dom'
// using promise
whenAttribute($myCoolHTMLElement, 'value').then(value => {
// do something...
});
// with a check function
whenAttribute($myCoolHTMLElement, 'value', {
check(newVal, oldVal) {
// make sure the value is a number
return typeof(newVal) === 'number';
}
}).then(value => {
// do something...
});Todo
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space