refactor: replace NodeSelector with Document in preparation for Typescript upgrade#1065
Conversation
|
Just out of curiosity and to learn; can you please link the resource or a github issue/document where we can read more about the |
Updated PR description accordingly, good suggestion! |
Irrelevant to this PR but ... if I'm understanding you correctly: I think this is not true. document.createElement does not modify the actual global document. It's simply a function create elements and does not create it within the document (you need to attach/append items you've created yourself). |
|
@waabid I agree/understand that |
Ooooh good point! |
Description of changes
Updating from Typescript 2.9 to 3.5 results in a variety of errors that look like this:
It looks like microsoft/TypeScript-DOM-lib-generator#647 was the point where it was removed, merged into a separate
ParentNodeinterface. We considered usingParentNodeinstead here, butDocumentseemed closer to the intended usage in most cases and led to the tests working more similarly to the product code than anything else, so that's what I went with.Replacing the usages with Document is a no-op in Typescript 2.9 (so nice to do as a separate PR, to make the eventual Typescript upgrade PR smaller). It also forces the affected tests to be a little bit better (they create test documents for the cases where the product passes real documents, rather than creating test nodes within a global document and hoping that they act similarly and that no other test touches global document state).
Pull request checklist
yarn test)<rootDir>/test-results/unit/coverageyarn precheckin)