jonnybot0 commented on code in PR #275:
URL: https://github.com/apache/groovy-geb/pull/275#discussion_r2164773577
##########
module/geb-core/src/main/groovy/geb/js/JavascriptInterface.groovy:
##########
@@ -53,8 +53,11 @@ class JavascriptInterface {
jsArgs = args[0..(args.size() - 2)]
}
+ if (script instanceof Closure) {
+ script = script()
+ }
if (!(script instanceof CharSequence)) {
- throw new IllegalArgumentException("The last argument to the js
function must be string-like")
+ throw new IllegalArgumentException("The last argument to the js
function must be string-like or a Closure returning a string-like")
Review Comment:
I think this is legitimate functionality, but it makes me wonder why we'd
only accept a `Closure`. Why not other functional interfaces, like `Callable`?
Gets tricky, of course, but your other PRs make me wonder if we aren't actually
hankering for a better designed API than this somewhat ad-hoc "throw stuff in
the method" JavaScriptInterface.
Can you say a bit more about the felt need behind this PR? What led you here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]