Skip to content

Commit 07b9c39

Browse files
committed
fix(form-field): superfluous whitespace when compiled with bazel
* 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 26c73e0 commit 07b9c39

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/lib/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/lib/input/input.spec.ts

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

366366
expect(inputEl.placeholder).toBe('Other placeholder');
367367
expect(labelEl).not.toBeNull();
368-
expect(labelEl.nativeElement.textContent).toMatch('Other placeholder');
369-
expect(labelEl.nativeElement.textContent).not.toMatch(/\*/g);
368+
expect(labelEl.nativeElement.textContent).toBe('Other placeholder');
370369
}));
371370

372371
it('supports placeholder element', fakeAsync(() => {
@@ -382,8 +381,7 @@ describe('MatInput without forms', () => {
382381

383382
el = fixture.debugElement.query(By.css('label'));
384383
expect(el).not.toBeNull();
385-
expect(el.nativeElement.textContent).toMatch('Other placeholder');
386-
expect(el.nativeElement.textContent).not.toMatch(/\*/g);
384+
expect(el.nativeElement.textContent).toBe('Other placeholder');
387385
}));
388386

389387
it('supports placeholder required star', fakeAsync(() => {
@@ -392,7 +390,8 @@ describe('MatInput without forms', () => {
392390

393391
let el = fixture.debugElement.query(By.css('label'));
394392
expect(el).not.toBeNull();
395-
expect(el.nativeElement.textContent).toMatch(/hello\s+\*/g);
393+
// The \xa0 hex-code represents the no-break space (&nbsp)
394+
expect(el.nativeElement.textContent).toBe('hello\xa0*');
396395
}));
397396

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

406405
expect(el).not.toBeNull();
407-
expect(el.nativeElement.textContent!.trim()).toMatch(/^hello$/);
406+
expect(el.nativeElement.textContent).toBe('hello');
408407
});
409408

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

423422
let el = fixture.debugElement.query(By.css('label'));
424423
expect(el).not.toBeNull();
425-
expect(el.nativeElement.textContent).toMatch(/hello\s+\*/g);
424+
// The \xa0 hex-code represents the no-break space (&nbsp)
425+
expect(el.nativeElement.textContent).toBe('hello\xa0*');
426426

427427
fixture.componentInstance.hideRequiredMarker = true;
428428
fixture.detectChanges();
429429

430-
expect(el.nativeElement.textContent).toMatch(/hello/g);
430+
expect(el.nativeElement.textContent).toBe('hello');
431431
}));
432432

433433
it('supports the disabled attribute as binding', fakeAsync(() => {
@@ -841,7 +841,7 @@ describe('MatInput without forms', () => {
841841

842842
expect(container.classList).toContain('mat-form-field-hide-placeholder');
843843
expect(container.classList).not.toContain('mat-form-field-should-float');
844-
expect(label.textContent.trim()).toBe('Label');
844+
expect(label.textContent).toBe('Label');
845845
expect(input.getAttribute('placeholder')).toBe('Placeholder');
846846

847847
input.value = 'Value';

0 commit comments

Comments
 (0)