You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ji...@apache.org on 2024/12/16 17:37:12 UTC
(couchdb) branch main updated: Add SpiderMonkey backward compatibility
This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/main by this push:
new 4147a8c83 Add SpiderMonkey backward compatibility
4147a8c83 is described below
commit 4147a8c83e1f660326ae2998da4d0bba570407ca
Author: Jiahui Li <li...@gmail.com>
AuthorDate: Fri Dec 13 15:12:40 2024 -0600
Add SpiderMonkey backward compatibility
- Using `for in` to fix syntax error when using SpiderMonkey 1.8.5
```
[2024-12-12T22:46:32.210Z] Failed to compile script.
[2024-12-12T22:46:32.210Z] SyntaxError: missing ; after for-loop initializer
[2024-12-12T22:46:32.210Z] Stacktrace:
[2024-12-12T22:46:32.210Z] @:0
```
- Add backward compatibility
---
share/server/util.js | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/share/server/util.js b/share/server/util.js
index a6d8d2a48..2de3eb096 100644
--- a/share/server/util.js
+++ b/share/server/util.js
@@ -116,7 +116,14 @@ var Couch = {
"Expression does not eval to a function. (" + source.toString() + ")"]);
};
},
- recursivelySeal : deepFreeze
+ recursivelySeal: function (obj) {
+ seal(obj);
+ for (var propname in obj) {
+ if (typeof obj[propname] == "object") {
+ arguments.callee(obj[propname]);
+ }
+ }
+ },
};
function errstr(e) {
@@ -157,10 +164,10 @@ function deepFreeze(object) {
const propNames = Reflect.ownKeys(object);
// Freeze properties before freezing self
- for (const name of propNames) {
- const value = object[name];
+ for (var i in propNames) {
+ const value = object[propNames[i]];
- if (((value && typeof value === "object") || typeof value === "function")) {
+ if ((value && typeof value === "object") || typeof value === "function") {
deepFreeze(value);
}
}