HubSpot / vex

A modern dialog library which is highly configurable and easy to style. #hubspot-open-source
http://github.hubspot.com/vex/docs/welcome
MIT License
6.92k stars 493 forks source link

`$.extend` in doc needs jQuery #228

Closed benomatis closed 7 years ago

benomatis commented 7 years ago

The doc refers to a jQuery plugin function $.extend even though it claims to be independent. You may want to "extend" (pun not intended) the script so it uses vanilla js for that.

Example:

var extend = function(out) {
  out = out || {};

  for (var i = 1; i < arguments.length; i++) {
    if (!arguments[i])
      continue;

    for (var key in arguments[i]) {
      if (arguments[i].hasOwnProperty(key))
        out[key] = arguments[i][key];
    }
  }

  return out;
};

extend({}, objA, objB);

Source: http://youmightnotneedjquery.com/#extend

bbatliner commented 7 years ago

$.extend is used in the docs, but the library itself does not depend on jQuery. The docs also recommend html-escape and _.escape for HTML content.

I agree, a better replacement would be Object.assign, the vanilla ES6 version of extend. Feel free to change the docs and make a PR if you want to see the change.

benomatis commented 7 years ago

I might be missing something, but haven't you mixed up extend with escape...?

bbatliner commented 7 years ago

I'm saying the docs make use of external libraries and try to point out where they do so. jQuery for some utility stuff and other modules for HTML escaping. Vex core does not have any dependencies.