Skip to content

Commit

Permalink
Fixup: small details
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabergia committed Nov 25, 2024
1 parent 03303eb commit 5067e6a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions rhino/src/main/java/org/mozilla/javascript/NativeString.java
Original file line number Diff line number Diff line change
Expand Up @@ -885,19 +885,19 @@ else if (Normalizer.Form.NFC.name().equals(formStr))
}
}

Object method = getPropSymbolMatchAll(cx, scope, regexp);
Object matcher = getPropSymbolMatchAll(cx, scope, regexp);
// If method is not undefined, it should be a Callable
if (method != null && !Undefined.isUndefined(method)) {
if (!(method instanceof Callable)) {
if (matcher != null && !Undefined.isUndefined(matcher)) {
if (!(matcher instanceof Callable)) {
throw ScriptRuntime.notFunctionError(
regexp, method, SymbolKey.MATCH_ALL.getName());
regexp, matcher, SymbolKey.MATCH_ALL.getName());
}
return ((Callable) method)
return ((Callable) matcher)
.call(
cx,
scope,
ScriptRuntime.toObject(scope, regexp),
new Object[] {thisObj});
new Object[] {o});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ protected boolean isDone(Context cx, Scriptable scope) {
} else if (!global) {
// Return false at this iteration, but true at the next. Point iii of the spec
nextDone = true;
return false;
}

// Increment index if matched empty string, as per the spec, point v.
Expand Down
2 changes: 1 addition & 1 deletion tests/testsrc/jstests/es2020/string-match-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function assertIteratorIsDone(iterator) {
assertEquals("07", results[5]);
})();

(function customSymbolMatchAllImplementation() {
(function nullRegExpShouldMatchLiteralNullString() {
const s = "to null or not to null";
const results = Array.from(s.matchAll(null));
assertEquals(2, results.length);
Expand Down

0 comments on commit 5067e6a

Please sign in to comment.