ResizeObserverEntry.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import {createReadOnlyRect} from './utils/geometry.js';
  2. import defineConfigurable from './utils/defineConfigurable.js';
  3. export default class ResizeObserverEntry {
  4. /**
  5. * Element size of which has changed.
  6. * Spec: https://wicg.github.io/ResizeObserver/#dom-resizeobserverentry-target
  7. *
  8. * @readonly
  9. * @type {Element}
  10. */
  11. target;
  12. /**
  13. * Element's content rectangle.
  14. * Spec: https://wicg.github.io/ResizeObserver/#dom-resizeobserverentry-contentrect
  15. *
  16. * @readonly
  17. * @type {DOMRectReadOnly}
  18. */
  19. contentRect;
  20. /**
  21. * Creates an instance of ResizeObserverEntry.
  22. *
  23. * @param {Element} target - Element that is being observed.
  24. * @param {DOMRectInit} rectInit - Data of the element's content rectangle.
  25. */
  26. constructor(target, rectInit) {
  27. const contentRect = createReadOnlyRect(rectInit);
  28. // According to the specification following properties are not writable
  29. // and are also not enumerable in the native implementation.
  30. //
  31. // Property accessors are not being used as they'd require to define a
  32. // private WeakMap storage which may cause memory leaks in browsers that
  33. // don't support this type of collections.
  34. defineConfigurable(this, {target, contentRect});
  35. }
  36. }