muu

DEPRECATED lightweight JS framework
git clone https://git.ce9e.org/muu.git

commit
f6f74f514a107581e0d7f3f356fc257276117636
parent
4c5c1dd2f445fa3e8467b63fdb75a0649a8122d4
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2016-01-24 17:48
Fix _.union compatibility

Diffstat

M src/muu-directive.js 2 +-
M src/muu-js-helpers.js 4 ++--
M test/test-js-helpers.js 2 +-

3 files changed, 4 insertions, 4 deletions


diff --git a/src/muu-directive.js b/src/muu-directive.js

@@ -92,7 +92,7 @@ define('muu-directive', ['muu-dom-helpers', 'muu-js-helpers'], function($, _) {
   92    92             // match the given selector.  findAll does the same with *relative
   93    93             // selectors* but does not seem to be available yet.
   94    94             var isolations = root.querySelectorAll('.muu-isolate');
   95    -1             var isolated = _.union(_.map(isolations, function(isolation) {
   -1    95             var isolated = _.union.apply(_, _.map(isolations, function(isolation) {
   96    96                 return isolation.querySelectorAll(selector);
   97    97             }));
   98    98 

diff --git a/src/muu-js-helpers.js b/src/muu-js-helpers.js

@@ -136,13 +136,13 @@ define('muu-js-helpers', [], function() {
  136   136     };
  137   137 
  138   138     /**
  139    -1      * @param {Array.<Array>} arrays
   -1   139      * @param {...Array} arrays
  140   140      * @return {Array}
  141   141      * @nosideeffects
  142   142      */
  143   143     _.union = function(arrays) {
  144   144         var results = [];
  145    -1         _.forEach(arrays, function(array) {
   -1   145         _.forEach(arguments, function(array) {
  146   146             _.forEach(array, function(item) {
  147   147                 if (_.indexOf(results, item) === -1) {
  148   148                     results.push(item);

diff --git a/test/test-js-helpers.js b/test/test-js-helpers.js

@@ -206,7 +206,7 @@ define(['muu-js-helpers'], function(_) {
  206   206         describe('union', function() {
  207   207             it('returns the set union of all passed lists', function() {
  208   208                 var input = [[1,1,2,3], [2,3,4], [4,5,3]];
  209    -1                 expect(_.union(input)).to.eql([1,2,3,4,5]);
   -1   209                 expect(_.union.apply(_, input)).to.eql([1,2,3,4,5]);
  210   210             });
  211   211         });
  212   212