CSS “contain” property
The contain
CSS property allows you to define an element as a style boundary in order to optimize the browser’s paints, layouts, composite, and style contexts calculations.
.el {
contain: strict;
}
The contain
CSS property allows you to define an element as a style boundary in order to optimize the browser’s paints, layouts, composite, and style contexts calculations.
.el {
contain: strict;
}
DOM node IDs are directly available in the window
object.
<div id='foo'></div>
console.log(window.foo) // HTMLElement
Though, you shouldn’t access the DOM that way.
We can create our own event types, listen to and emmit them from anywhere, and implement event driven behaviors.
$el.addEventListener('foo', () => {
console.log('received foo event')
})
$el.dispatchEvent(new CustomEvent('foo'))
// 'received foo event'
JavaScript allows you to intercept when an object property is accessed or assigned to.
const foo = {
bar: 42,
get bar() { return this.bar + 1 }
}
console.log(foo.bar) // 43
Any object containing a then()
property — also called a thenable — can be turned into a promise.
const foo = {
then: fn => fn(42)
}
Promise.resolve(foo).then(console.log) // 42