Skip to content

Commit 4ebda5e

Browse files
committed
add convert from Java strings to dom strings.
1 parent 3e32dd4 commit 4ebda5e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/de/inetsoftware/jwebassembly/web/JSObject.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package de.inetsoftware.jwebassembly.web;
1717

18+
import javax.annotation.Nonnull;
19+
1820
import de.inetsoftware.jwebassembly.api.annotation.Import;
1921

2022
/**
@@ -79,7 +81,7 @@ protected JSObject( Object peer ) {
7981
* @return the value of the property
8082
*/
8183
protected <T> T get( String propName ) {
82-
return get0( peer, propName );
84+
return get0( peer, domString( propName ) );
8385
}
8486

8587
/**
@@ -110,6 +112,19 @@ protected <T> T get( String propName ) {
110112
* @return the return value
111113
*/
112114
protected <T> T invoke( String methodName, Object param1 ) {
113-
return invoke1( peer, methodName, param1 );
115+
return invoke1( peer, domString( methodName ), param1 );
116+
}
117+
118+
/**
119+
* Get the dom string from a java string https://developer.mozilla.org/de/docs/Web/API/DOMString
120+
*
121+
* @param str
122+
* the Java string
123+
* @return dom string
124+
*/
125+
public static String domString( @Nonnull String str ) {
126+
// in pure we return simple the string
127+
// in wasm code this method should be replaced
128+
return str;
114129
}
115130
}

0 commit comments

Comments
 (0)