Skip to content
This repository was archived by the owner on May 20, 2023. It is now read-only.

Commit 3b83416

Browse files
matanlureynshahan
authored andcommitted
Migrate from ElementRef --> {Element|HtmlElement}.
This is a no-op, but avoids indirection, extra allocation, and dynamic calls. PiperOrigin-RevId: 189416813
1 parent e4b26e6 commit 3b83416

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

lib/material_datepicker/material_date_grid_base.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,14 @@ abstract class ForcedScrollDirectiveHost {
291291
visibility: Visibility.all,
292292
)
293293
class ForcedScrollDirective {
294-
final ElementRef _element;
294+
final HtmlElement _element;
295295
final DomService _domService;
296296

297297
ForcedScrollDirective(
298-
this._element, this._domService, ForcedScrollDirectiveHost calendar) {
298+
this._element,
299+
this._domService,
300+
ForcedScrollDirectiveHost calendar,
301+
) {
299302
// Trying to inject this directive into the calendar using @ViewQuery causes
300303
// the tests' tearDown to fail... so do this nastiness instead.
301304
// TODO(google): It didn't look like the test bed was doing anything
@@ -305,12 +308,11 @@ class ForcedScrollDirective {
305308
calendar.attachScroller(this);
306309
}
307310

308-
int get height => (_element.nativeElement as HtmlElement).clientHeight;
311+
int get height => _element.clientHeight;
309312

310313
void forceScroll(int scrollTop) {
311314
_domService.scheduleWrite(() {
312-
Element elm = _element.nativeElement;
313-
elm.scrollTop = scrollTop;
315+
_element.scrollTop = scrollTop;
314316
});
315317
}
316318
}

lib/material_datepicker/material_month_picker.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ class MaterialMonthPickerComponent implements OnInit, AfterViewInit, OnDestroy {
251251
}
252252

253253
@ViewChild('container')
254-
set container(ElementRef containerRef) {
255-
_container = containerRef.nativeElement;
256-
_scroller = _container.parent;
254+
set container(Element container) {
255+
_container = container;
256+
_scroller = container.parent;
257257
}
258258

259259
@override

lib/src/scorecard/scorecard_bar.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ class ScorecardBarDirective implements OnInit, OnDestroy, AfterViewChecked {
4646
int _transform = 0;
4747
int _buttonSize = 0;
4848

49-
ScorecardBarDirective(this._domService, ElementRef elementRef,
50-
@Optional() @Inject(rtlToken) bool isRtl)
51-
: _element = elementRef.nativeElement {
49+
ScorecardBarDirective(
50+
this._domService,
51+
this._element,
52+
@Optional() @Inject(rtlToken) bool isRtl,
53+
) {
5254
_isRtl = isRtl ?? false;
5355
}
5456

0 commit comments

Comments
 (0)