function matchesSelector_SLOW(element, selector) {
  let root = element;
  while (root.parentNode) {
    root = root.parentNode;
  }

  const all = root.querySelectorAll(selector);
  return Array.prototype.indexOf.call(all, element) !== -1;
}
The CSSCore module specifies the API (and implements most of the methods)
that should be used when dealing with the display of elements (via their
CSS classes and visibility on screen. It is an API focused on mutating the
display and not reading it as no logical state should be encoded in the
display of elements.