GraphicsUtil.js 614 B

12345678910111213141516171819202122232425262728293031
  1. import {
  2. query as domQuery
  3. } from 'min-dom';
  4. /**
  5. * SVGs for elements are generated by the {@link GraphicsFactory}.
  6. *
  7. * This utility gives quick access to the important semantic
  8. * parts of an element.
  9. */
  10. /**
  11. * Returns the visual part of a diagram element
  12. *
  13. * @param {Snap<SVGElement>} gfx
  14. *
  15. * @return {Snap<SVGElement>}
  16. */
  17. export function getVisual(gfx) {
  18. return domQuery('.djs-visual', gfx);
  19. }
  20. /**
  21. * Returns the children for a given diagram element.
  22. *
  23. * @param {Snap<SVGElement>} gfx
  24. * @return {Snap<SVGElement>}
  25. */
  26. export function getChildren(gfx) {
  27. return gfx.parentNode.childNodes[1];
  28. }