javascripts/govuk/details.polyfill.js
function (node, match) {
      do {
        if (!node || node.nodeName.toLowerCase() === match) {
          break
        }
        node = node.parentNode
      } while (node)

      return node
    }
function (node, match) {
      do {
        if (!node || node.nodeName.toLowerCase() === match) {
          break
        }
        node = node.parentNode
      } while (node)

      return node
    }
function ( node , match ) { do { if ( ! node || node . nodeName . toLowerCase ( ) === match ) { break } node = node . parentNode } while ( node ) return node }
Get the nearest ancestor element of a node that matches a given tag name
Get the nearest ancestor element of a node that matches a given tag name