Skip to content

Commit 1bf4e9e

Browse files
committed
Implement JSValue.isUndefined instance method
1 parent 03c834a commit 1bf4e9e

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

sdk/src/org.graalvm.webimage.api/src/org/graalvm/webimage/api/JSUndefined.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public static JSUndefined instance() {
5555
JSUndefined() {
5656
}
5757

58+
@Override
59+
public boolean isUndefined() {
60+
return true;
61+
}
62+
5863
@Override
5964
public String typeof() {
6065
return "undefined";

sdk/src/org.graalvm.webimage.api/src/org/graalvm/webimage/api/JSValue.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,19 @@ public static <R> R checkedCoerce(Object value, Class<R> cls) {
7676
}
7777

7878
/**
79-
* Checks whether the given JSValue is the JavaScript 'undefined' value.
79+
* Checks whether the given value is the JavaScript {@code undefined} value.
8080
*
81-
* @param value the JSValue to check
82-
* @return true if the value is an instance of JSUndefined, false otherwise
81+
* @see #isUndefined()
8382
*/
8483
public static boolean isUndefined(JSValue value) {
85-
return value instanceof JSUndefined;
84+
return value != null && value.isUndefined();
85+
}
86+
87+
/**
88+
* Checks whether this is the JavaScript {@code undefined} value.
89+
*/
90+
public boolean isUndefined() {
91+
return false;
8692
}
8793

8894
public static JSUndefined undefined() {

0 commit comments

Comments
 (0)