版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

47 regels
1.5 KiB

  1. import INode from '../nodes/node/INode';
  2. import Range from './Range';
  3. import IRangeBoundaryPoint from './IRangeBoundaryPoint';
  4. /**
  5. * Range utility.
  6. *
  7. * Based on:
  8. * https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/range/boundary-point.js.
  9. */
  10. export default class RangeUtility {
  11. /**
  12. * Compares boundary points.
  13. *
  14. * Based on logic from:
  15. * https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/range/boundary-point.js
  16. *
  17. * @see https://dom.spec.whatwg.org/#concept-range-bp-after
  18. * @param pointA Point A.
  19. * @param pointB Point B.
  20. * @returns A number, -1, 0, or 1, indicating whether the corresponding boundary-point of the Range is respectively before, equal to, or after the corresponding boundary-point of sourceRange.
  21. */
  22. static compareBoundaryPointsPosition(pointA: IRangeBoundaryPoint, pointB: IRangeBoundaryPoint): number;
  23. /**
  24. * Validates a boundary point.
  25. *
  26. * @throws DOMException
  27. * @param point Boundary point.
  28. */
  29. static validateBoundaryPoint(point: IRangeBoundaryPoint): void;
  30. /**
  31. * Returns "true" if contained.
  32. *
  33. * @param node Node.
  34. * @param range Range.
  35. * @returns "true" if contained.
  36. */
  37. static isContained(node: INode, range: Range): boolean;
  38. /**
  39. * Returns "true" if partially contained.
  40. *
  41. * @param node Node.
  42. * @param range Range.
  43. * @returns "true" if partially contained.
  44. */
  45. static isPartiallyContained(node: INode, range: Range): boolean;
  46. }