From d23b0e6f758d78228e44615aaec8c406846fef34 Mon Sep 17 00:00:00 2001 From: Sherman Hui Date: 2020年10月22日 21:36:11 -0700 Subject: [PATCH] docs: update `waitForElementToBeRemoved` Add clarification that a callback function is the recommended argument type to be passed into the `callback` argument of `waitForElementToBeRemoved` as DOM nodes are not guaranteed to be removed in frameworks such as React. They may be updated rather than removed as referenced in issue #409. --- docs/dom-testing-library/api-async.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/dom-testing-library/api-async.md b/docs/dom-testing-library/api-async.md index d311ba112..bf595c501 100644 --- a/docs/dom-testing-library/api-async.md +++ b/docs/dom-testing-library/api-async.md @@ -83,8 +83,12 @@ To wait for the removal of element(s) from the DOM you can use `waitForElementToBeRemoved`. The `waitForElementToBeRemoved` function is a small wrapper around the `waitFor` utility. -The first argument must be an element, array of elements, or a callback which -returns an element or array of elements. +The first argument must be a callback which returns an element or array of +elements, an element, or an array of elements. The recommended approach is to +use a callback that returns an element or array of elements. This is because DOM +nodes aren't guaranteed to be removed but rather updated in frameworks such as +React. This could lead to unexpected results when passing an element or array of +elements as the element is not actually removed, but instead updated. Here is an example where the promise resolves because the element is removed:

AltStyle によって変換されたページ (->オリジナル) /