/* globals define, module */

/**
 * A simple library to help you escape HTML using template strings.
 *
 * It's the counterpart to our eslint "no-unsafe-innerhtml" plugin that helps us
 * avoid unsafe coding practices.
 * A full write-up of the Hows and Whys are documented
 * for developers at
 *  https://developer.mozilla.org/en-US/Firefox_OS/Security/Security_Automation
 * with additional background information and design docs at
 *  https://wiki.mozilla.org/User:Fbraun/Gaia/SafeinnerHTMLRoadmap
 *
 */
(function (root, factory) {
  'use strict';
  if (typeof define === 'function' && define.amd) {
    define(factory);
  } else if (typeof exports === 'object') {
    module.exports = factory();
  } else {
    root.Sanitizer = factory();
  }
}(this, function () {
  'use strict';

  var Sanitizer = {
    _entity: /[&<>"'/]/g,

    _entities: {
      '&': '&amp;',
      '<': '&lt;',
      '>': '&gt;',
      '"': '&quot;',
      '\'': '&apos;',
      '/': '&#x2F;'
    },

    getEntity: function (s) {
      return Sanitizer._entities[s];
    },

    /**
     * Escapes HTML for all values in a tagged template string.
     */
    escapeHTML: function (strings) {
      var result = '';

      for (var i = 0; i < strings.length; i++) {
        result += strings[i];
        var value = arguments[i + 1] || '';
        if (i < values.length) {
          result += String(value).replace(Sanitizer._entity,
            Sanitizer.getEntity);
        }
      }

      return result;
    },
    /**
     * Escapes HTML and returns a wrapped object to be used during DOM insertion
     */
    createSafeHTML: function (strings) {
      var _len = arguments.length;
      var values = new Array(_len > 1 ? _len - 1 : 0);
      for (var _key = 1; _key < _len; _key++) {
        values[_key - 1] = arguments[_key];
      }

      var escaped = Sanitizer.escapeHTML.apply(Sanitizer,
        [strings].concat(values));
      return {
        __html: escaped,
        toString: function () {
          return '[object WrappedHTMLObject]';
        },
        info: 'This is a wrapped HTML object. See https://developer.mozilla.or'+
          'g/en-US/Firefox_OS/Security/Security_Automation for more.'
      };
    },
    /**
     * Unwrap safe HTML created by createSafeHTML or a custom replacement that
     * underwent security review.
     */
    unwrapSafeHTML: function () {
      var _len = arguments.length;
      var htmlObjects = new Array(_len);
      for (var _key = 0; _key < _len; _key++) {
        htmlObjects[_key] = arguments[_key];
      }

      var markupList = htmlObjects.map(function(obj) {
        return obj.__html;
      });
      return markupList.join('');
    }
  };

  return Sanitizer;

}));

@@ -1156,32 +1156,43 @@
 unction (strings
+, ...values
 ) %7B%0A      var re
@@ -1286,52 +1286,8 @@
 i%5D;%0A
-        var value = arguments%5Bi + 1%5D %7C%7C '';%0A
     
@@ -1347,16 +1347,20 @@
 ng(value
+s%5Bi%5D
 ).replac
@@ -1599,294 +1599,83 @@
 ings
-) %7B%0A      var _len = arguments.length;%0A      var values = new Array(_len %3E 1 ? _len - 1 : 0);%0A      for (var _key = 1; _key %3C _len; _key++) %7B%0A        values%5B_key - 1%5D = arguments%5B_key%5D;%0A      %7D%0A%0A      var escaped = Sanitizer.escapeHTML.apply(Sanitizer,%0A        %5Bstrings%5D.concat(
+, ...values) %7B%0A      var escaped = Sanitizer.escapeHTML(strings, ...
 values)
-)
 ;%0A  
@@ -2132,189 +2132,25 @@
 on (
-) %7B%0A      var _len = arguments.length;%0A      var htmlObjects = new Array(_len);%0A      for (var _key = 0; _key %3C _len; _key++) %7B%0A        htmlObjects%5B_key%5D = arguments%5B_key%5D;%0A      %7D%0A
+...htmlObjects) %7B
 %0A   

Revert "Replacing spread operators by their es5 equivalent"