javascripts/govuk/details.polyfill.js
function (node, callback) {
      GOVUK.details.addEvent(node, 'keypress', function (e, target) {
        // When the key gets pressed - check if it is enter or space
        if (GOVUK.details.charCode(e) === GOVUK.details.KEY_ENTER || GOVUK.details.charCode(e) === GOVUK.details.KEY_SPACE) {
          if (target.nodeName.toLowerCase() === 'summary') {
            // Prevent space from scrolling the page
            // and enter from submitting a form
            GOVUK.details.preventDefault(e)
            // Click to let the click event do all the necessary action
            if (target.click) {
              target.click()
            } else {
              // except Safari 5.1 and under don't support .click() here
              callback(e, target)
            }
          }
        }
      })

      // Prevent keyup to prevent clicking twice in Firefox when using space key
      GOVUK.details.addEvent(node, 'keyup', function (e, target) {
        if (GOVUK.details.charCode(e) === GOVUK.details.KEY_SPACE) {
          if (target.nodeName === 'SUMMARY') {
            GOVUK.details.preventDefault(e)
          }
        }
      })

      GOVUK.details.addEvent(node, 'click', function (e, target) {
        callback(e, target)
      })
    }
function (node, callback) {
      GOVUK.details.addEvent(node, 'keypress', function (e, target) {
        // When the key gets pressed - check if it is enter or space
        if (GOVUK.details.charCode(e) === GOVUK.details.KEY_ENTER || GOVUK.details.charCode(e) === GOVUK.details.KEY_SPACE) {
          if (target.nodeName.toLowerCase() === 'summary') {
            // Prevent space from scrolling the page
            // and enter from submitting a form
            GOVUK.details.preventDefault(e)
            // Click to let the click event do all the necessary action
            if (target.click) {
              target.click()
            } else {
              // except Safari 5.1 and under don't support .click() here
              callback(e, target)
            }
          }
        }
      })

      // Prevent keyup to prevent clicking twice in Firefox when using space key
      GOVUK.details.addEvent(node, 'keyup', function (e, target) {
        if (GOVUK.details.charCode(e) === GOVUK.details.KEY_SPACE) {
          if (target.nodeName === 'SUMMARY') {
            GOVUK.details.preventDefault(e)
          }
        }
      })

      GOVUK.details.addEvent(node, 'click', function (e, target) {
        callback(e, target)
      })
    }
function ( node , callback ) { GOVUK . details . addEvent ( node , 'keypress' , function ( e , target ) { // When the key gets pressed - check if it is enter or space if ( GOVUK . details . charCode ( e ) === GOVUK . details . KEY_ENTER || GOVUK . details . charCode ( e ) === GOVUK . details . KEY_SPACE ) { if ( target . nodeName . toLowerCase ( ) === 'summary' ) { // Prevent space from scrolling the page // and enter from submitting a form GOVUK . details . preventDefault ( e ) // Click to let the click event do all the necessary action if ( target . click ) { target . click ( ) } else { // except Safari 5.1 and under don't support .click() here callback ( e , target ) } } } } ) // Prevent keyup to prevent clicking twice in Firefox when using space key GOVUK . details . addEvent ( node , 'keyup' , function ( e , target ) { if ( GOVUK . details . charCode ( e ) === GOVUK . details . KEY_SPACE ) { if ( target . nodeName === 'SUMMARY' ) { GOVUK . details . preventDefault ( e ) } } } ) GOVUK . details . addEvent ( node , 'click' , function ( e , target ) { callback ( e , target ) } ) }
Handle cross-modal click events
Handle cross - modal click events