code: function connectedToTheDom(node) {
        // IE does not have contains method on document element, only body   
        var container = node.ownerDocument.contains ? node.ownerDocument : node.ownerDocument.body;
        return container.contains(node);
      }
docs: returns true if the element is contained within a document