docs: private void listenOnEndAttribute() throws IOException {
  
          if (lastElement == null) {
              return;
          }
  
          // no nonce written -> do it
          if ("script".equalsIgnoreCase(lastElement) && LangUtils.isValueBlank(lastNonce)) {
              getWrapped().writeAttribute("nonce", cspState.getNonce(), null);
          }
  
          if (lastEvents != null && !lastEvents.isEmpty()) {
              String id = lastId;
  
              // no id written -> generate a new one and write it
              // otherwise we can't identify the element for our scripts
              if (LangUtils.isValueBlank(id)) {
                  id = lastElement.toLowerCase() + "-" + UUID.randomUUID().toString();
                  getWrapped().writeAttribute("id", id, null);
              }
  
              // add current collected events to our state
              cspState.getEventHandlers().put(id, lastEvents);
          }
  
          reset();
      }