fix(aio): switch from innerText
to textContent
to support older browsers
`innerText` is not supported in Firefox prior to v45. In most cases (at least the ones we are interested in), `innerText` and `textContent` work equally well, but `textContent` is more performant (as it doesn't require a reflow). From [MDN][1] on the differences of `innerText` vs `textContent`: > - [...] > - `innerText` is aware of style and will not return the text of hidden > elements, whereas `textContent` will. > - As `innerText` is aware of CSS styling, it will trigger a reflow, whereas > `textContent` will not. > - [...] [1]: https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#Differences_from_innerText Fixes #17585
This commit is contained in:

committed by
Hans Larsen

parent
ab81c1c068
commit
62957fa515
@ -27,7 +27,7 @@ describe('AppComponent', function () {
|
||||
it('should have expected <h1> text', () => {
|
||||
fixture.detectChanges();
|
||||
const h1 = de.nativeElement;
|
||||
expect(h1.innerText).toMatch(/angular/i,
|
||||
expect(h1.textContent).toMatch(/angular/i,
|
||||
'<h1> should say something about "Angular"');
|
||||
});
|
||||
});
|
||||
|
@ -111,7 +111,7 @@ export class AppComponent implements AfterViewInit, OnInit {
|
||||
}
|
||||
|
||||
onSave(event: KeyboardEvent) {
|
||||
let evtMsg = event ? ' Event target is ' + (<HTMLElement>event.target).innerText : '';
|
||||
let evtMsg = event ? ' Event target is ' + (<HTMLElement>event.target).textContent : '';
|
||||
this.alert('Saved.' + evtMsg);
|
||||
if (event) { event.stopPropagation(); }
|
||||
}
|
||||
|
Reference in New Issue
Block a user