File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed
lib/java/ydoc-polyfill/src
main/java/org/enso/ydoc/polyfill/web
test/java/org/enso/ydoc/polyfill/web Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 6
6
import java .util .function .Function ;
7
7
import org .enso .ydoc .polyfill .Arguments ;
8
8
import org .graalvm .polyglot .Value ;
9
+ import org .graalvm .polyglot .proxy .ProxyArray ;
9
10
import org .graalvm .polyglot .proxy .ProxyExecutable ;
10
11
import org .slf4j .Logger ;
11
12
import org .slf4j .LoggerFactory ;
@@ -86,8 +87,9 @@ private static final class EventStore {
86
87
this .listeners = listeners ;
87
88
}
88
89
89
- public Value [] getEventListeners (String type ) {
90
- return listeners .getOrDefault (type , Set .of ()).toArray (new Value [0 ]);
90
+ public ProxyArray getEventListeners (String type ) {
91
+ var arr = listeners .getOrDefault (type , Set .of ()).toArray (new Value [0 ]);
92
+ return ProxyArray .fromArray ((Object []) arr );
91
93
}
92
94
93
95
public void addEventListener (String type , Value listener ) {
Original file line number Diff line number Diff line change 11
11
public final class WebEnvironment {
12
12
13
13
public static final HostAccess .Builder defaultHostAccess =
14
- HostAccess .newBuilder (HostAccess .EXPLICIT ).allowArrayAccess ( true ). allowBufferAccess (true );
14
+ HostAccess .newBuilder (HostAccess .EXPLICIT ).allowBufferAccess (true );
15
15
16
16
private WebEnvironment () {}
17
17
Original file line number Diff line number Diff line change @@ -43,7 +43,15 @@ public void dispatchEvent() throws Exception {
43
43
"""
44
44
var count = 0;
45
45
var et = new EventTarget();
46
- et.addEventListener('inc', () => count += 1);
46
+ var l = () => count += 1;
47
+ et.addEventListener('inc', l);
48
+ var arr = et.getEventListeners('inc');
49
+ if (arr.length != 1) {
50
+ throw 'Expecting one listener';
51
+ }
52
+ if (arr[0] != l) {
53
+ throw 'Expecting the one listener!';
54
+ }
47
55
et.dispatchEvent({type: 'inc'});
48
56
count;
49
57
""" ;
You can’t perform that action at this time.
0 commit comments