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

IgniteUI / igniteui-webcomponents / 14702825363

28 Apr 2025 07:42AM UTC coverage: 98.263% (-0.02%) from 98.279%
14702825363

Pull #1352

github

web-flow
Merge 6e058e971 into 0f89d7575
Pull Request #1352: Refactor Tab component

4590 of 4823 branches covered (95.17%)

Branch coverage included in aggregate %.

582 of 592 new or added lines in 5 files covered. (98.31%)

1 existing line in 1 file now uncovered.

29414 of 29782 relevant lines covered (98.76%)

453.65 hits per line

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

90.91
/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 readonly _host: ReactiveControllerHost & Element;
10✔
28
  private readonly _targets = new Set<Element>();
10✔
29
  private readonly _observer!: ResizeObserver;
10✔
30
  private readonly _config: ResizeControllerConfig;
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
    /* c8 ignore next 3 */
10✔
44
    if (isServer) {
10✔
45
      return;
10✔
46
    }
10✔
47

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

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

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

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

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

10✔
75
  /** @internal */
10✔
76
  public hostDisconnected(): void {
10✔
77
    this._observer.disconnect();
37✔
78
  }
37✔
79
}
10✔
80

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