Skip to content

Commit d11a624

Browse files
committed
Bridge: Fix nested objects.
1 parent 544a032 commit d11a624

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

bridge/src/main/resources/dev/webview/webview_java/bridge/BridgeScript.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ const Bridge = {
106106
root = root[part];
107107
}
108108

109-
root[propertyName] = proxy;
109+
Object.defineProperty(root, propertyName, {
110+
value: proxy,
111+
writable: true,
112+
configurable: true
113+
});
110114
},
111115

112116
get(id, property) {

bridge/src/test/java/com/example/webview_java/BridgeExample.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public static void main(String[] args) {
5151

5252
public static class TestObject extends JavascriptObject {
5353

54+
public final NestedTestObject nested = new NestedTestObject();
55+
5456
@JavascriptValue(allowSet = false, watchForMutate = true)
5557
public long nanoTime = -1;
5658
{
@@ -71,4 +73,13 @@ public void ringBell() {
7173

7274
}
7375

76+
public static class NestedTestObject extends JavascriptObject {
77+
78+
@JavascriptFunction
79+
public void test() {
80+
System.out.println("Test");
81+
}
82+
83+
}
84+
7485
}

0 commit comments

Comments
 (0)