Blag Recipes About
zzzzBov
24 - Mar - 2021

TIL: node.isConnected exists #

Shout out to Lea Verou for sharing Node.isConnected. I've had a few cases where I've needed to determine if a node is in the DOM. I've usually written something along the lines of:

const inDOM = (node) => {
  for (let n = node; n; n = n.parentNode) {
    if (n === document) {
      return true;
    }
  }
  return false;
};

Having a native property for this will be helpful.

⇐ “Modern HTML Boilerplate” “Media Query Ranges” ⇒

Copyright © zzzzBov