@diplodoc/transform 4.74.0 → 4.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/js/yfm.js CHANGED
@@ -510,6 +510,7 @@
510
510
  var TOOLTIP_BASE_CLASS = "yfm yfm-tooltip";
511
511
  var TOOLTIP_OPEN_CLASS = "open";
512
512
  var TOOLTIP_DATA_ATTR = "data-tooltip-id";
513
+ var TOOLTIP_LIVE_REGION_CLASS = "yfm-tooltip-live-region";
513
514
  var DEFAULT_OFFSET_VALUES = { mainAxis: 5 };
514
515
  var OPPOSITE_SIDES = {
515
516
  top: "bottom",
@@ -697,6 +698,7 @@
697
698
  function createTooltipFactory(options = {}) {
698
699
  const { closeDelay = 1e3, additionalClassName } = options;
699
700
  let initialized = false;
701
+ let liveRegion = null;
700
702
  const state = {
701
703
  currentId: null,
702
704
  timer: null,
@@ -729,13 +731,19 @@
729
731
  detachTooltip(tooltip3);
730
732
  state.currentId = null;
731
733
  }
734
+ if (liveRegion) {
735
+ liveRegion.textContent = "";
736
+ }
732
737
  };
733
738
  const show = (reference, text) => {
734
739
  hide();
735
- const tooltip3 = createTooltipElement({ text, className: additionalClassName });
740
+ const tooltip3 = createTooltipElement({ className: additionalClassName });
736
741
  const update = updateTooltipPosition.bind(null, options, reference, tooltip3);
737
742
  state.currentId = tooltip3.id;
738
- attachTooltip(tooltip3, reference);
743
+ attachTooltip(tooltip3, reference, text);
744
+ if (liveRegion) {
745
+ liveRegion.textContent = text;
746
+ }
739
747
  state.unsubscribe = subscribeToScroll(reference, update);
740
748
  tooltip3.classList.add(TOOLTIP_OPEN_CLASS);
741
749
  update();
@@ -757,6 +765,10 @@
757
765
  const init = () => {
758
766
  if (!initialized) {
759
767
  initialized = true;
768
+ liveRegion = document.createElement("div");
769
+ liveRegion.className = TOOLTIP_LIVE_REGION_CLASS;
770
+ liveRegion.setAttribute("aria-live", "assertive");
771
+ document.body.appendChild(liveRegion);
760
772
  window.addEventListener("scroll", handleUpdate);
761
773
  window.addEventListener("resize", handleUpdate);
762
774
  }
@@ -780,24 +792,18 @@
780
792
  };
781
793
  }
782
794
  function createTooltipElement(options) {
783
- const { text, className } = options;
795
+ const { className } = options;
784
796
  const id = generateId();
785
797
  const tooltip3 = document.createElement("div");
786
798
  tooltip3.id = id;
787
799
  tooltip3.className = className ? `${TOOLTIP_BASE_CLASS} ${className}` : TOOLTIP_BASE_CLASS;
788
- tooltip3.setAttribute("role", "tooltip");
789
- tooltip3.setAttribute("aria-live", "polite");
790
- tooltip3.textContent = text;
791
800
  return tooltip3;
792
801
  }
793
- function attachTooltip(tooltip3, reference) {
802
+ function attachTooltip(tooltip3, reference, text) {
794
803
  const container2 = document.querySelector(PAGE_CONTAINER_SELECTOR) || document.body;
795
- const ariaLive = reference.getAttribute("aria-live");
796
804
  reference.setAttribute(TOOLTIP_DATA_ATTR, tooltip3.id);
797
- if (ariaLive) {
798
- tooltip3.setAttribute("aria-live", ariaLive);
799
- }
800
805
  container2.appendChild(tooltip3);
806
+ tooltip3.textContent = text;
801
807
  }
802
808
  function detachTooltip(tooltip3) {
803
809
  if (tooltip3.id) {