Clipper/joplin-webclipper/content_scripts/Readability.js
function(node, tagName, maxDepth, filterFn) {
    maxDepth = maxDepth || 3;
    tagName = tagName.toUpperCase();
    var depth = 0;
    while (node.parentNode) {
      if (maxDepth > 0 && depth > maxDepth)
        return false;
      if (node.parentNode.tagName === tagName && (!filterFn || filterFn(node.parentNode)))
        return true;
      node = node.parentNode;
      depth++;
    }
    return false;
  }
function(node, tagName, maxDepth, filterFn) {
    maxDepth = maxDepth || 3;
    tagName = tagName.toUpperCase();
    var depth = 0;
    while (node.parentNode) {
      if (maxDepth > 0 && depth > maxDepth)
        return false;
      if (node.parentNode.tagName === tagName && (!filterFn || filterFn(node.parentNode)))
        return true;
      node = node.parentNode;
      depth++;
    }
    return false;
  }
function ( node , tagName , maxDepth , filterFn ) { maxDepth = maxDepth || 3 ; tagName = tagName . toUpperCase ( ) ; var depth = 0 ; while ( node . parentNode ) { if ( maxDepth > 0 && depth > maxDepth ) return false ; if ( node . parentNode . tagName === tagName && ( ! filterFn || filterFn ( node . parentNode ) ) ) return true ; node = node . parentNode ; depth ++ ; } return false ; }
Check if a given node has one of its ancestor tag name matching the
provided one.
@param  HTMLElement node
@param  String      tagName
@param  Number      maxDepth
@param  Function    filterFn a filter to invoke to determine whether this node 'counts'
@return Boolean
Check if a given node has one of its ancestor tag name matching the provided one .