]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1540425 - Remove Array.forEach from sorttable.js
authorKohei Yoshino <kohei.yoshino@gmail.com>
Wed, 12 Jun 2019 19:44:54 +0000 (15:44 -0400)
committerGitHub <noreply@github.com>
Wed, 12 Jun 2019 19:44:54 +0000 (15:44 -0400)
extensions/BMO/web/js/sorttable.js

index c20f026479a5156c641e7fa2758f04817dee8b5e..79a5c8b5fbab61d8eed7ba5acb7c0b0cc051f53d 100644 (file)
@@ -30,12 +30,7 @@ sorttable = {
 
     sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
 
-    forEach(document.getElementsByTagName('table'), function(table) {
-      if (table.className.search(/\bsortable\b/) != -1) {
-        sorttable.makeSortable(table);
-      }
-    });
-
+    document.querySelectorAll('table.sortable').forEach($table => sorttable.makeSortable($table));
   },
 
   /*
@@ -652,58 +647,3 @@ fixEvent.preventDefault = function() {
 fixEvent.stopPropagation = function() {
   this.cancelBubble = true;
 }
-
-// Dean's forEach: http://dean.edwards.name/base/forEach.js
-/*
-  forEach, version 1.0
-  Copyright 2006, Dean Edwards
-  License: http://www.opensource.org/licenses/mit-license.php
-*/
-
-// array-like enumeration
-if (!Array.forEach) { // mozilla already supports this
-  Array.forEach = function(array, block, context) {
-    for (var i = 0; i < array.length; i++) {
-      block.call(context, array[i], i, array);
-    }
-  };
-}
-
-// generic enumeration
-Function.prototype.forEach = function(object, block, context) {
-  for (var key in object) {
-    if (typeof this.prototype[key] == "undefined") {
-      block.call(context, object[key], key, object);
-    }
-  }
-};
-
-// character enumeration
-String.forEach = function(string, block, context) {
-  Array.forEach(string.split(""), function(chr, index) {
-    block.call(context, chr, index, string);
-  });
-};
-
-// globally resolve forEach enumeration
-var forEach = function(object, block, context) {
-  if (object) {
-    var resolve = Object; // default
-    if (object instanceof Function) {
-      // functions have a "length" property
-      resolve = Function;
-    } else if (object.forEach instanceof Function) {
-      // the object implements a custom forEach method so use that
-      object.forEach(block, context);
-      return;
-    } else if (typeof object == "string") {
-      // the object is a string
-      resolve = String;
-    } else if (typeof object.length == "number") {
-      // the object is array-like
-      resolve = Array;
-    }
-    resolve.forEach(object, block, context);
-  }
-};
-