Every so often I discover a property in JavaScript objects that I didn’t know existed, oftentimes using another trick to accomplish the same functionality. One such property I just learned about was isConnected
, a node property that attached to a context (i.e. document
).
Here’s how to use Node.prototype.isConnected
:
const el = document.createElement('div'); el.isConnected; // false document.body.appendChild(el); el.isConnected; // true
I used to run parentNode
checks on the element to see if it had been injected but that’s not always accurate, so I’m glad isConnected
exists!
Vertically Centering with Flexbox
Vertically centering sibling child contents is a task we’ve long needed on the web but has always seemed way more difficult than it should be. We initially used tables to accomplish the task, then moved on to CSS and JavaScript tricks because table layout was horribly…
Highlight Table Rows, Columns, and Cells Using MooTools 1.2.3
Row highlighting and individual cell highlighting in tables is pretty simple in every browser that supports :hover on all elements (basically everything except IE6). Column highlighting is a bit more difficult. Luckily MooTools 1.2.3 makes the process easy. The XHTML A normal table. The cells…