• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

uNmAnNeR / imaskjs / 7192372037

13 Dec 2023 08:07AM UTC coverage: 30.682%. Remained the same
7192372037

push

github

uNmAnNeR
up deps

0 of 2 branches covered (0.0%)

Branch coverage included in aggregate %.

27 of 86 relevant lines covered (31.4%)

0.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/packages/imask/src/controls/mask-element.ts
1
import IMask from '../core/holder';
1✔
2

3

4
export
5
type ElementEvent =
6
  'selectionChange' |
7
  'input' |
8
  'drop' |
9
  'click' |
10
  'focus' |
11
  'commit';
12

13
/**  Generic element API to use with mask */
14
export default
15
abstract class MaskElement {
16
  /** */
17
  abstract _unsafeSelectionStart: number | null;
18
  /** */
19
  abstract _unsafeSelectionEnd: number | null;
20
  /** */
21
  abstract value: string;
22

23
  /** Safely returns selection start */
24
  get selectionStart (): number {
25
    let start;
26
    try {
27
      start = this._unsafeSelectionStart;
28
    } catch {}
29

30
    return start != null ?
31
      start :
32
      this.value.length;
33
  }
34

35
  /** Safely returns selection end */
36
  get selectionEnd (): number {
37
    let end;
38
    try {
39
      end = this._unsafeSelectionEnd;
40
    } catch {}
41

42
    return end != null ?
43
      end :
44
      this.value.length;
45
  }
46

47
  /** Safely sets element selection */
48
  select (start: number, end: number) {
49
    if (start == null || end == null ||
50
      start === this.selectionStart && end === this.selectionEnd) return;
51

52
    try {
53
      this._unsafeSelect(start, end);
54
    } catch {}
55
  }
56

57
  /** */
58
  get isActive (): boolean { return false; }
59
  /** */
60
  abstract _unsafeSelect (start: number, end: number): void;
61
  /** */
62
  abstract bindEvents (handlers: {[key in ElementEvent]: Function}): void;
63
  /** */
64
  abstract unbindEvents (): void
65
}
66

67

68
IMask.MaskElement = MaskElement;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc