天天看點

SAP Spartacus PR 10507第二次嘗試

move this.requiredtabindex = -1 into ngAfterViewInit, due to two reasons:

a. before change: In the context of requiresExplicitTabIndex execution, tag does not have href attribute populated yet. For detail see this discussion thread

as a result, we have to put it to ngOnAfterViewInit, at that time the href attribute of a tag is already populated with correct value:

SAP Spartacus PR 10507第二次嘗試

b. The problem here is that we have a situation where the view generation process (which ngAfterViewInit is a part of) is itself further modifying the data that we are trying to display in the first place.

In unit test code it reports error message:

SAP Spartacus PR 10507第二次嘗試

See this blog.

So I use setTimeout() to defer the code to another Javascript Virtual Machine turn.

Since now this.requiredtabindex = -1 is wrapped to setTimeout and executed asynchronously, some unit test will fail:

SAP Spartacus PR 10507第二次嘗試

繼續閱讀