docs: function attach(node) {
      var addListeners = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
  
      $listModals(node).forEach(function (modal_node) {
  
        var iLisible = Math.random().toString(32).slice(2, 12);
        var wrapperBody = findById(WRAPPER_PAGE_JS);
        var body = doc.querySelector('body');
  
        modal_node.setAttribute('id', MODAL_ID_PREFIX + iLisible);
        modal_node.setAttribute(ATTR_HASPOPUP, ATTR_HASPOPUP_VALUE);
  
        if (wrapperBody === null || wrapperBody.length === 0) {
          var wrapper = doc.createElement('DIV');
          wrapper.setAttribute('id', WRAPPER_PAGE_JS);
          wrapInner(body, wrapper);
        }
      });
  
      if (addListeners) {
  
        /* listeners */
        ['click', 'keydown'].forEach(function (eventName) {
  
          doc.body.addEventListener(eventName, function (e) {
  
            // click on link modal
            var parentModalLauncher = searchParent(e.target, MODAL_JS_CLASS);
            if ((hasClass(e.target, MODAL_JS_CLASS) === true || parentModalLauncher !== '') && eventName === 'click') {
              var body = doc.querySelector('body');
              var modalLauncher = parentModalLauncher !== '' ? findById(parentModalLauncher) : e.target;
              var modalPrefixClass = modalLauncher.hasAttribute(MODAL_PREFIX_CLASS_ATTR) === true ? modalLauncher.getAttribute(MODAL_PREFIX_CLASS_ATTR) + '-' : '';
              var modalText = modalLauncher.hasAttribute(MODAL_TEXT_ATTR) === true ? modalLauncher.getAttribute(MODAL_TEXT_ATTR) : '';
              var modalContentId = modalLauncher.hasAttribute(MODAL_CONTENT_ID_ATTR) === true ? modalLauncher.getAttribute(MODAL_CONTENT_ID_ATTR) : '';
              var modalDescribedById = modalLauncher.hasAttribute(MODAL_DESCRIBEDBY_ID_ATTR) === true ? modalLauncher.getAttribute(MODAL_DESCRIBEDBY_ID_ATTR) : '';
              var modalTitle = modalLauncher.hasAttribute(MODAL_TITLE_ATTR) === true ? modalLauncher.getAttribute(MODAL_TITLE_ATTR) : '';
              var modalCloseText = modalLauncher.hasAttribute(MODAL_CLOSE_TEXT_ATTR) === true ? modalLauncher.getAttribute(MODAL_CLOSE_TEXT_ATTR) : MODAL_OVERLAY_TXT;
              var modalCloseTitle = modalLauncher.hasAttribute(MODAL_CLOSE_TITLE_ATTR) === true ? modalLauncher.getAttribute(MODAL_CLOSE_TITLE_ATTR) : modalCloseText;
              var modalCloseImgPath = modalLauncher.hasAttribute(MODAL_CLOSE_IMG_ATTR) === true ? modalLauncher.getAttribute(MODAL_CLOSE_IMG_ATTR) : '';
              var backgroundEnabled = modalLauncher.hasAttribute(MODAL_DATA_BACKGROUND_ATTR) === true ? modalLauncher.getAttribute(MODAL_DATA_BACKGROUND_ATTR) : '';
              var modalGiveFocusToId = modalLauncher.hasAttribute(MODAL_FOCUS_TO_ATTR) === true ? modalLauncher.getAttribute(MODAL_FOCUS_TO_ATTR) : '';
  
              var wrapperBody = findById(WRAPPER_PAGE_JS);
  
              // insert overlay
              body.insertAdjacentHTML('beforeEnd', createOverlay({
                text: modalCloseTitle,
                backgroundEnabled: backgroundEnabled,
                prefixClass: modalPrefixClass
              }));
  
              // insert modal
              body.insertAdjacentHTML('beforeEnd', createModal({
                modalText: modalText,
                modalPrefixClass: modalPrefixClass,
                backgroundEnabled: modalContentId,
                modalTitle: modalTitle,
                modalCloseText: modalCloseText,
                modalCloseTitle: modalCloseTitle,
                modalCloseImgPath: modalCloseImgPath,
                modalContentId: modalContentId,
                modalDescribedById: modalDescribedById,
                modalFocusBackId: modalLauncher.getAttribute('id')
              }));
  
              // hide page
              wrapperBody.setAttribute(ATTR_HIDDEN, 'true');
  
              // add class noscroll to body
              addClass(body, NO_SCROLL_CLASS);
  
              // give focus to close button or specified element
              var closeButton = findById(MODAL_BUTTON_JS_ID);
              if (modalGiveFocusToId !== '') {
                var focusTo = findById(modalGiveFocusToId);
                if (focusTo) {
                  focusTo.focus();
                } else {
                  closeButton.focus();
                }
              } else {
                closeButton.focus();
              }
  
              e.preventDefault();
            }
  
            // click on close button or on overlay not blocked
            var parentButton = searchParent(e.target, MODAL_BUTTON_JS_CLASS);
            if ((e.target.getAttribute('id') === MODAL_BUTTON_JS_ID || parentButton !== '' || e.target.getAttribute('id') === MODAL_OVERLAY_ID || hasClass(e.target, MODAL_BUTTON_JS_CLASS) === true) && eventName === 'click') {
              var body = doc.querySelector('body');
              var wrapperBody = findById(WRAPPER_PAGE_JS);
              var modal = findById(MODAL_JS_ID);
              var modalContent = findById(MODAL_CONTENT_JS_ID) ? findById(MODAL_CONTENT_JS_ID).innerHTML : '';
              var overlay = findById(MODAL_OVERLAY_ID);
              var modalButtonClose = findById(MODAL_BUTTON_JS_ID);
              var modalFocusBackId = modalButtonClose.getAttribute(MODAL_BUTTON_FOCUS_BACK_ID);
              var contentBackId = modalButtonClose.getAttribute(MODAL_BUTTON_CONTENT_BACK_ID);
              var backgroundEnabled = overlay.getAttribute(MODAL_OVERLAY_BG_ENABLED_ATTR);
  
              if (!(e.target.getAttribute('id') === MODAL_OVERLAY_ID && backgroundEnabled === 'disabled')) {
  
                closeModal({
                  modal: modal,
                  modalContent: modalContent,
                  overlay: overlay,
                  modalFocusBackId: modalFocusBackId,
                  contentBackId: contentBackId,
                  backgroundEnabled: backgroundEnabled,
                  fromId: e.target.getAttribute('id')
                });
  
                // show back page
                wrapperBody.removeAttribute(ATTR_HIDDEN);
  
                // remove class noscroll to body
                removeClass(body, NO_SCROLL_CLASS);
              }
            }
  
            // strike a key when modal opened
            if (findById(MODAL_JS_ID) && eventName === 'keydown') {
              var body = doc.querySelector('body');
              var wrapperBody = findById(WRAPPER_PAGE_JS);
              var modal = findById(MODAL_JS_ID);
              var modalContent = findById(MODAL_CONTENT_JS_ID) ? findById(MODAL_CONTENT_JS_ID).innerHTML : '';
              var overlay = findById(MODAL_OVERLAY_ID);
              var modalButtonClose = findById(MODAL_BUTTON_JS_ID);
              var modalFocusBackId = modalButtonClose.getAttribute(MODAL_BUTTON_FOCUS_BACK_ID);
              var contentBackId = modalButtonClose.getAttribute(MODAL_BUTTON_CONTENT_BACK_ID);
              var $listFocusables = [].slice.call(modal.querySelectorAll(FOCUSABLE_ELEMENTS_STRING));
  
              // esc
              if (e.keyCode === 27) {
  
                closeModal({
                  modal: modal,
                  modalContent: modalContent,
                  overlay: overlay,
                  modalFocusBackId: modalFocusBackId,
                  contentBackId: contentBackId
                });
  
                // show back page
                wrapperBody.removeAttribute(ATTR_HIDDEN);
  
                // remove class noscroll to body
                removeClass(body, NO_SCROLL_CLASS);
              }
  
              // tab or Maj Tab in modal => capture focus
              if (e.keyCode === 9 && $listFocusables.indexOf(e.target) >= 0) {
  
                // maj-tab on first element focusable => focus on last
                if (e.shiftKey) {
                  if (e.target === $listFocusables[0]) {
                    $listFocusables[$listFocusables.length - 1].focus();
                    e.preventDefault();
                  }
                } else {
                  // tab on last element focusable => focus on first
                  if (e.target === $listFocusables[$listFocusables.length - 1]) {
                    $listFocusables[0].focus();
                    e.preventDefault();
                  }
                }
              }
  
              // tab outside modal => put it in focus
              if (e.keyCode === 9 && $listFocusables.indexOf(e.target) === -1) {
                e.preventDefault();
                $listFocusables[0].focus();
              }
            }
          }, true);
        });
      }
    }