fix(core): log error instead of warning for unknown properties and elements (#35798)

Changes the Ivy unknown element/property messages from being logged with `console.warn` to `console.error`. This should make them a bit more visible without breaking existing apps. Furthermore, a lot of folks filter out warning messages in the dev tools' console, whereas errors are usually still shown.

Fixes #35699.

PR Close #35798
This commit is contained in:
crisbeto
2020-03-03 17:42:44 +01:00
committed by atscott
parent ed44073a58
commit 00f3c58bb9
7 changed files with 47 additions and 47 deletions

View File

@ -97,7 +97,7 @@ describe('NgModule', () => {
});
describe('schemas', () => {
onlyInIvy('Unknown property warning logged instead of throwing an error')
onlyInIvy('Unknown property logs an error message instead of throwing')
.it('should throw on unknown props if NO_ERRORS_SCHEMA is absent', () => {
@Component({
selector: 'my-comp',
@ -120,7 +120,7 @@ describe('NgModule', () => {
TestBed.configureTestingModule({imports: [MyModule]});
const spy = spyOn(console, 'warn');
const spy = spyOn(console, 'error');
const fixture = TestBed.createComponent(MyComp);
fixture.detectChanges();
expect(spy.calls.mostRecent().args[0])
@ -185,15 +185,15 @@ describe('NgModule', () => {
}).not.toThrow();
});
onlyInIvy('unknown element check logs a warning rather than throwing')
.it('should warn about unknown element without CUSTOM_ELEMENTS_SCHEMA for element with dash in tag name',
onlyInIvy('unknown element check logs an error message rather than throwing')
.it('should log an error about unknown element without CUSTOM_ELEMENTS_SCHEMA for element with dash in tag name',
() => {
@Component({template: `<custom-el></custom-el>`})
class MyComp {
}
const spy = spyOn(console, 'warn');
const spy = spyOn(console, 'error');
TestBed.configureTestingModule({declarations: [MyComp]});
const fixture = TestBed.createComponent(MyComp);
fixture.detectChanges();
@ -215,14 +215,14 @@ describe('NgModule', () => {
}).toThrowError(/'custom-el' is not a known element/);
});
onlyInIvy('unknown element check logs a warning rather than throwing')
.it('should warn about unknown element without CUSTOM_ELEMENTS_SCHEMA for element without dash in tag name',
onlyInIvy('unknown element check logs an error message rather than throwing')
.it('should log an error about unknown element without CUSTOM_ELEMENTS_SCHEMA for element without dash in tag name',
() => {
@Component({template: `<custom></custom>`})
class MyComp {
}
const spy = spyOn(console, 'warn');
const spy = spyOn(console, 'error');
TestBed.configureTestingModule({declarations: [MyComp]});
const fixture = TestBed.createComponent(MyComp);
fixture.detectChanges();
@ -245,8 +245,8 @@ describe('NgModule', () => {
});
onlyInIvy('test relies on Ivy-specific AOT format')
.it('should not log unknown element warning for AOT-compiled components', () => {
const spy = spyOn(console, 'warn');
.it('should not log unknown element error for AOT-compiled components', () => {
const spy = spyOn(console, 'error');
/*
* @Component({
@ -310,13 +310,13 @@ describe('NgModule', () => {
expect(spy).not.toHaveBeenCalled();
});
onlyInIvy('unknown element check logs a warning rather than throwing')
.it('should not warn about unknown elements with CUSTOM_ELEMENTS_SCHEMA', () => {
onlyInIvy('unknown element check logs an error message rather than throwing')
.it('should not log an error about unknown elements with CUSTOM_ELEMENTS_SCHEMA', () => {
@Component({template: `<custom-el></custom-el>`})
class MyComp {
}
const spy = spyOn(console, 'warn');
const spy = spyOn(console, 'error');
TestBed.configureTestingModule({
declarations: [MyComp],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
@ -344,13 +344,13 @@ describe('NgModule', () => {
}).not.toThrow();
});
onlyInIvy('unknown element check logs a warning rather than throwing')
.it('should not warn about unknown elements with NO_ERRORS_SCHEMA', () => {
onlyInIvy('unknown element check logs an error message rather than throwing')
.it('should not log an error about unknown elements with NO_ERRORS_SCHEMA', () => {
@Component({template: `<custom-el></custom-el>`})
class MyComp {
}
const spy = spyOn(console, 'warn');
const spy = spyOn(console, 'error');
TestBed.configureTestingModule({
declarations: [MyComp],
schemas: [NO_ERRORS_SCHEMA],
@ -378,8 +378,8 @@ describe('NgModule', () => {
}).not.toThrow();
});
onlyInIvy('unknown element check logs a warning rather than throwing')
.it('should not warn about unknown elements if element matches a directive', () => {
onlyInIvy('unknown element check logs an error message rather than throwing')
.it('should not log an error about unknown elements if element matches a directive', () => {
@Component({
selector: 'custom-el',
template: '',
@ -391,7 +391,7 @@ describe('NgModule', () => {
class MyComp {
}
const spy = spyOn(console, 'warn');
const spy = spyOn(console, 'error');
TestBed.configureTestingModule({declarations: [MyComp, CustomEl]});
const fixture = TestBed.createComponent(MyComp);
@ -420,8 +420,8 @@ describe('NgModule', () => {
}).not.toThrow();
});
onlyInIvy('unknown element check logs a warning rather than throwing')
.it('should not warn for HTML elements inside an SVG foreignObject', () => {
onlyInIvy('unknown element check logs an error message rather than throwing')
.it('should not log an error for HTML elements inside an SVG foreignObject', () => {
@Component({
template: `
<svg>
@ -438,7 +438,7 @@ describe('NgModule', () => {
class MyModule {
}
const spy = spyOn(console, 'warn');
const spy = spyOn(console, 'error');
TestBed.configureTestingModule({imports: [MyModule]});
const fixture = TestBed.createComponent(MyComp);