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

IgniteUI / igniteui-webcomponents / 13265423658

11 Feb 2025 02:39PM UTC coverage: 98.224% (-0.04%) from 98.265%
13265423658

Pull #1352

github

web-flow
Merge 107e76eb5 into 44d06629e
Pull Request #1352: Refactor Tab component

3847 of 4049 branches covered (95.01%)

Branch coverage included in aggregate %.

420 of 433 new or added lines in 4 files covered. (97.0%)

2 existing lines in 1 file now uncovered.

24857 of 25174 relevant lines covered (98.74%)

468.4 hits per line

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

88.12
/src/components/common/controllers/resize-observer.ts
1
import {
10✔
2
  type ReactiveController,
10✔
3
  type ReactiveControllerHost,
10✔
4
  isServer,
10✔
5
} from 'lit';
10✔
6

10✔
7
type ResizeControllerCallback = (
10✔
8
  ...args: Parameters<ResizeObserverCallback>
10✔
9
) => unknown;
10✔
10

10✔
11
/** Configuration for initializing a resize controller. */
10✔
12
export interface ResizeControllerConfig {
10✔
13
  /** The callback function to run when a resize mutation is triggered. */
10✔
14
  callback: ResizeControllerCallback;
10✔
15
  /** Configuration options passed to the underlying ResizeObserver. */
10✔
16
  options?: ResizeObserverOptions;
10✔
17
  /**
10✔
18
   * The initial target element to observe for resize mutations.
10✔
19
   *
10✔
20
   * If not provided, the host element will be set as initial target.
10✔
21
   * Pass in `null` to skip setting an initial target.
10✔
22
   */
10✔
23
  target?: Element | null;
10✔
24
}
10✔
25

10✔
26
class ResizeController implements ReactiveController {
10✔
27
  private _host: ReactiveControllerHost & Element;
10✔
28
  private _targets = new Set<Element>();
10✔
29
  private _config: ResizeControllerConfig;
10✔
30
  private _observer!: ResizeObserver;
10✔
31

10✔
32
  constructor(
10✔
33
    host: ReactiveControllerHost & Element,
38✔
34
    config: ResizeControllerConfig
38✔
35
  ) {
38✔
36
    this._host = host;
38✔
37
    this._config = config;
38✔
38

38✔
39
    if (this._config.target !== null) {
38!
NEW
40
      this._targets.add(this._config.target ?? host);
×
NEW
41
    }
×
42

38✔
43
    if (isServer) {
38!
NEW
44
      return;
×
NEW
45
    }
×
46

38✔
47
    this._observer = new ResizeObserver((entries) =>
38✔
48
      this._config.callback.call(this._host, entries, this._observer)
25✔
49
    );
38✔
50

38✔
51
    host.addController(this);
38✔
52
  }
38✔
53

10✔
54
  /** Starts observing the `targe` element. */
10✔
55
  public observe(target: Element): void {
10✔
56
    this._targets.add(target);
38✔
57
    this._observer.observe(target, this._config.options);
38✔
58
    this._host.requestUpdate();
38✔
59
  }
38✔
60

10✔
61
  /** Stops observing the `target` element. */
10✔
62
  public unobserve(target: Element): void {
10✔
NEW
63
    this._targets.delete(target);
×
NEW
64
    this._observer.unobserve(target);
×
NEW
65
  }
×
66

10✔
67
  public hostConnected(): void {
10✔
68
    for (const target of this._targets) {
38!
NEW
69
      this.observe(target);
×
NEW
70
    }
×
71
  }
38✔
72

10✔
73
  public hostDisconnected(): void {
10✔
74
    this.disconnect();
37✔
75
  }
37✔
76

10✔
77
  protected disconnect(): void {
10✔
78
    this._observer.disconnect();
37✔
79
  }
37✔
80
}
10✔
81

10✔
82
/**
10✔
83
 * Creates a new resize controller bound to the given `host`
10✔
84
 * with {@link ResizeControllerConfig | `config`}.
10✔
85
 */
10✔
86
export function createResizeController(
10✔
87
  host: ReactiveControllerHost & Element,
38✔
88
  config: ResizeControllerConfig
38✔
89
) {
38✔
90
  return new ResizeController(host, config);
38✔
91
}
38✔
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