dist/wpt.js
/**
     * Initializes state, state history, and adds event listeners to monitor
     * state changes.
     */
Initializes state, state history, and adds event listeners to monitor
state changes.
Initializes state state history and adds event listeners to monitor state changes .
function PageLifecycle() {
      var _this;
      _this = _EventTargetShim.call(this) || this;
      var state = getCurrentState();
      _this._state = state;
      _this._unsavedChanges = []; 
      _this._handleEvents = _this._handleEvents.bind(_assertThisInitialized(_this)); 
      EVENTS.forEach(function (evt) {
        return addEventListener(evt, _this._handleEvents, true);
      }); 
      if (IS_SAFARI) {
        addEventListener(EVENT_BEFOREUNLOAD, function (evt) {
          _this._safariBeforeUnloadTimeout = setTimeout(function () {
            if (!(evt.defaultPrevented || evt.returnValue.length > 0)) {
              _this._dispatchChangesIfNeeded(evt, PAGE_LIFECYCLE_STATE_HIDDEN);
            }
          }, 0);
        });
      }
      return _this;
    }
function PageLifecycle ( ) { var _this ; _this = _EventTargetShim . call ( this ) || this ; var state = getCurrentState ( ) ; _this . _state = state ; _this . _unsavedChanges = [ ] ; _this . _handleEvents = _this . _handleEvents . bind ( _assertThisInitialized ( _this ) ) ; EVENTS . forEach ( function ( evt ) { return addEventListener ( evt , _this . _handleEvents , true ) ; } ) ; if ( IS_SAFARI ) { addEventListener ( EVENT_BEFOREUNLOAD , function ( evt ) { _this . _safariBeforeUnloadTimeout = setTimeout ( function ( ) { if ( ! ( evt . defaultPrevented || evt . returnValue . length > 0 ) ) { _this . _dispatchChangesIfNeeded ( evt , PAGE_LIFECYCLE_STATE_HIDDEN ) ; } } , 0 ) ; } ) ; } return _this ; }
Initializes state, state history, and adds event listeners to monitor
 state changes.
Initializes state state history and adds event listeners to monitor state changes .
// Bind the callback and add event listeners. // Add capturing events on window so they run immediately. // Safari does not reliably fire the `pagehide` or `visibilitychange` // events when closing a tab, so we have to use `beforeunload` with a // timeout to check whether the default action was prevented. // - https://bugs.webkit.org/show_bug.cgi?id=151610 // - https://bugs.webkit.org/show_bug.cgi?id=151234 // NOTE: we only add this to Safari because adding it to Firefox would // prevent the page from being eligible for bfcache.