|
1 |
| -import {Component, inject, Provider, signal, ViewChild} from '@angular/core'; |
| 1 | +import {Component, inject, Provider, signal, ViewChild, ViewEncapsulation} from '@angular/core'; |
2 | 2 | import {ComponentFixture, fakeAsync, flush, TestBed} from '@angular/core/testing';
|
3 | 3 | import {NoopAnimationsModule} from '@angular/platform-browser/animations';
|
4 | 4 | import {DateAdapter, provideNativeDateAdapter} from '../core';
|
@@ -299,6 +299,15 @@ describe('MatTimepicker', () => {
|
299 | 299 | fixture.detectChanges();
|
300 | 300 | }).toThrowError(/MatTimepicker can only be registered with one input at a time/);
|
301 | 301 | });
|
| 302 | + |
| 303 | + it('input should be properly formatted when in shadow DOM', () => { |
| 304 | + const fixture = TestBed.createComponent(TimepickerInShadowDom); |
| 305 | + fixture.detectChanges(); // So that TimepickerInput.timepicker gets set. |
| 306 | + const input = fixture.nativeElement.shadowRoot.querySelector('.mat-timepicker-input'); |
| 307 | + typeInElement(input, '13:37'); |
| 308 | + fixture.detectChanges(); |
| 309 | + expect(input.value).toBe('13:37'); |
| 310 | + }); |
302 | 311 | });
|
303 | 312 |
|
304 | 313 | describe('opening and closing', () => {
|
@@ -1413,3 +1422,13 @@ class TimepickerWithMultipleInputs {}
|
1413 | 1422 | class TimepickerWithoutInput {
|
1414 | 1423 | @ViewChild(MatTimepicker) timepicker: MatTimepicker<Date>;
|
1415 | 1424 | }
|
| 1425 | + |
| 1426 | +@Component({ |
| 1427 | + template: ` |
| 1428 | + <input [matTimepicker]="picker" /> |
| 1429 | + <mat-timepicker #picker /> |
| 1430 | + `, |
| 1431 | + imports: [MatTimepicker, MatTimepickerInput], |
| 1432 | + encapsulation: ViewEncapsulation.ShadowDom, |
| 1433 | +}) |
| 1434 | +class TimepickerInShadowDom {} |
0 commit comments