Skip to content

Replace underscore with lodash

Tomas Vik requested to merge underscore-to-lodash into develop

The interface of lodash v3 and underscore is identical for all the methods we are using. The only difference I was able to find was implementation of _.extend where underscore uses inherited properties, not just own properties. This seemed to affect only popover and dropdown implementation (I looked at every _.extend statement) and in both I replaced the code as per following snippet:

   getTargetPosition: function() {
     var el = this.targetElement;
  
-    var pos = _.extend({}, el.getBoundingClientRect(), this.$targetElement.offset());
+    const pos = {};
+    _.forIn(el.getBoundingClientRect(), (v, k) => (pos[k] = v));
+    _.forIn(this.$targetElement.offset(), (v, k) => (pos[k] = v));

     return pos;
   },

I haven't removed the underscore-wrapper because I'm suspecting that it is used when loading underscore as a backbone dependency.

Testing strategy:

  1. Test following functionality without vue-left-menu feature toggle
    • popover, dropdown
    • eyeballs, drag&drop, switching rooms, unread items, appevents

Related issue from the old issue tracker:
https://github.com/troupe/gitter-webapp/issues/126

Edited by Tomas Vik

Merge request reports