Skip to content

Commit cf11ed2

Browse files
devversionjelbourn
authored andcommitted
fix(form-field): superfluous whitespace when compiled with bazel (#13911)
Fixes that the form-field does not render properly when being compiled through Bazel. This is because the whitespace is being preserved due to Bazel not minifying HTML files like we do with Gulp.
1 parent 8dffd8e commit cf11ed2

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/material/form-field/form-field.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<!-- @breaking-change 8.0.0 remove in favor of mat-label element an placeholder attr. -->
4444
<ng-container *ngSwitchCase="false">
4545
<ng-content select="mat-placeholder"></ng-content>
46-
{{_control.placeholder}}
46+
<span>{{_control.placeholder}}</span>
4747
</ng-container>
4848

4949
<ng-content select="mat-label" *ngSwitchCase="true"></ng-content>

src/material/input/input.spec.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,7 @@ describe('MatInput without forms', () => {
367367

368368
expect(inputEl.placeholder).toBe('Other placeholder');
369369
expect(labelEl).not.toBeNull();
370-
expect(labelEl.nativeElement.textContent).toMatch('Other placeholder');
371-
expect(labelEl.nativeElement.textContent).not.toMatch(/\*/g);
370+
expect(labelEl.nativeElement.textContent).toBe('Other placeholder');
372371
}));
373372

374373
it('supports placeholder element', fakeAsync(() => {
@@ -384,8 +383,7 @@ describe('MatInput without forms', () => {
384383

385384
el = fixture.debugElement.query(By.css('label'));
386385
expect(el).not.toBeNull();
387-
expect(el.nativeElement.textContent).toMatch('Other placeholder');
388-
expect(el.nativeElement.textContent).not.toMatch(/\*/g);
386+
expect(el.nativeElement.textContent).toBe('Other placeholder');
389387
}));
390388

391389
it('supports placeholder required star', fakeAsync(() => {
@@ -394,7 +392,7 @@ describe('MatInput without forms', () => {
394392

395393
let el = fixture.debugElement.query(By.css('label'));
396394
expect(el).not.toBeNull();
397-
expect(el.nativeElement.textContent).toMatch(/hello +\*/g);
395+
expect(el.nativeElement.textContent).toBe('hello *');
398396
}));
399397

400398
it('should hide the required star if input is disabled', () => {
@@ -406,8 +404,7 @@ describe('MatInput without forms', () => {
406404
const el = fixture.debugElement.query(By.css('label'));
407405

408406
expect(el).not.toBeNull();
409-
expect(el.nativeElement.textContent!.trim()).toMatch(/^hello$/);
410-
expect(el.nativeElement.textContent).not.toMatch(/\*/g);
407+
expect(el.nativeElement.textContent).toBe('hello');
411408
});
412409

413410
it('should hide the required star from screen readers', fakeAsync(() => {
@@ -425,13 +422,12 @@ describe('MatInput without forms', () => {
425422

426423
let el = fixture.debugElement.query(By.css('label'));
427424
expect(el).not.toBeNull();
428-
expect(el.nativeElement.textContent).toMatch(/hello +\*/g);
425+
expect(el.nativeElement.textContent).toBe('hello *');
429426

430427
fixture.componentInstance.hideRequiredMarker = true;
431428
fixture.detectChanges();
432429

433-
expect(el.nativeElement.textContent).toMatch(/hello/g);
434-
expect(el.nativeElement.textContent).not.toMatch(/\*/g);
430+
expect(el.nativeElement.textContent).toBe('hello');
435431
}));
436432

437433
it('supports the disabled attribute as binding', fakeAsync(() => {
@@ -894,7 +890,7 @@ describe('MatInput without forms', () => {
894890

895891
expect(container.classList).toContain('mat-form-field-hide-placeholder');
896892
expect(container.classList).not.toContain('mat-form-field-should-float');
897-
expect(label.textContent.trim()).toBe('Label');
893+
expect(label.textContent).toBe('Label');
898894
expect(input.getAttribute('placeholder')).toBe('Placeholder');
899895

900896
input.value = 'Value';

0 commit comments

Comments
 (0)