Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-4392

[JS Performances] remove all eval

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 4.2.0
    • None
    • None
    • None

      Replace all evals by something like

      function executeFunctionByName(functionName, context /*, args */) {
          var args = Array.prototype.slice.call(arguments, 2);
          var namespaces = functionName.split(".");
          var func = namespaces.pop();
          for (var i = 0; i < namespaces.length; i++) {
              context = context[namespaces[i]];
          }
          return context[func].apply(context, args);
      }
      

          [CMS-4392] [JS Performances] remove all eval

          The Ametys object give several methods for this optimisation
          So in Runtime there is only one eval that stays...

          Raphaël Franchet added a comment - The Ametys object give several methods for this optimisation So in Runtime there is only one eval that stays...

          Here is a patch introducing a related JS function which is able to retrieve an object by name.
          It can be used to retrieve a function for example (which is a JS object) and to execute it with the some args if necessary.

          An example can be seen in this code snippet:
          http://jsfiddle.net/zoom/YAQuM/

          Thibaut Rizzi (Inactive) added a comment - Here is a patch introducing a related JS function which is able to retrieve an object by name. It can be used to retrieve a function for example (which is a JS object) and to execute it with the some args if necessary. An example can be seen in this code snippet: http://jsfiddle.net/zoom/YAQuM/

            Unassigned Unassigned
            raphael Raphaël Franchet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: