You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2024/10/28 18:17:34 UTC

(couchdb) 01/01: Document junk before function() SM 1.8.5 vs 78+

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch document-inval-js-before-js-function-def
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit fbf71318c77e35379e0bce6613e87713e7bf5e22
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Mon Oct 28 14:14:47 2024 -0400

    Document junk before function() SM 1.8.5 vs 78+
    
    In SpiderMonkey 1.8.5 allow this type of syntax:
    
    ```
    foo : function(doc){emit(doc._id, 1);}
    ```
    
    While later versions started throwing a compilation error.
---
 src/docs/src/best-practices/jsdevel.rst | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/docs/src/best-practices/jsdevel.rst b/src/docs/src/best-practices/jsdevel.rst
index 8f19673ff..639b55b75 100644
--- a/src/docs/src/best-practices/jsdevel.rst
+++ b/src/docs/src/best-practices/jsdevel.rst
@@ -247,6 +247,21 @@ might have emitted the "Invalid Date" string, while in later SpiderMonkey
 engines all the emit results from that document will be skipped, since view
 functions skip view results if an exception is thrown.
 
+9. Invalid JavaScript before function definition
+
+SpiderMoneky version ``1.8.5`` allowed the invalid ``term : function(...)``
+syntax. So a view function like the following worked and produced successfull
+view results. In later version, at least as of ``78+``, that function will fail
+with a compilation error:
+
+.. code-block:: javascript
+
+   "views": {
+            "v1": {
+                 "map": "foo : function(doc){emit(doc._id, 1);}"
+        }
+    }
+
 Using QuickJS
 =============