Skip to content

Commit 5155f67

Browse files
committed
same change for index/Symbol based put implementation
1 parent 62e4f88 commit 5155f67

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

rhino/src/main/java/org/mozilla/javascript/ScriptableObject.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,7 +2506,10 @@ public static void putProperty(Scriptable obj, Symbol key, Object value) {
25062506
/** Variant of putProperty to handle super[key] = value where key is a symbol */
25072507
public static void putSuperProperty(
25082508
Scriptable superObj, Scriptable thisObj, Symbol key, Object value) {
2509-
ensureSymbolScriptable(superObj).put(key, thisObj, value);
2509+
// in contrast to putProperty we start searching at superObj
2510+
Scriptable base = getBase(superObj, key);
2511+
if (base == null) base = superObj;
2512+
ensureSymbolScriptable(base).put(key, thisObj, value);
25102513
}
25112514

25122515
/**
@@ -2554,7 +2557,10 @@ public static void putProperty(Scriptable obj, int index, Object value) {
25542557
/** Variant of putProperty to handle super[index] = value where index is integer */
25552558
public static void putSuperProperty(
25562559
Scriptable superObj, Scriptable thisObj, int index, Object value) {
2557-
superObj.put(index, thisObj, value);
2560+
// in contrast to putProperty we start searching at superObj
2561+
Scriptable base = getBase(superObj, index);
2562+
if (base == null) base = superObj;
2563+
base.put(index, thisObj, value);
25582564
}
25592565

25602566
/**

0 commit comments

Comments
 (0)