From 7a6a9e88514198c57a3dadd0c68281aaffe7219d Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Dec 2020 06:10:42 +0800 Subject: [PATCH] [6.x] Add Browser::elsewhereWhenAvailable(). (#846) Signed-off-by: Mior Muhammad Zaki --- src/Browser.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Browser.php b/src/Browser.php index f32ac2dbf..f956f882b 100644 --- a/src/Browser.php +++ b/src/Browser.php @@ -518,6 +518,20 @@ public function elsewhere($selector, Closure $callback) return $this; } + /** + * Execute a Closure outside of the current browser scope when the selector is available. + * + * @param string $selector + * @param \Closure $callback + * @return $this + */ + public function elsewhereWhenAvailable($selector, Closure $callback) + { + return $this->elsewhere('', function ($browser) use ($selector, $callback) { + $this->whenAvailable($selector, $callback); + }); + } + /** * Set the current component state. *