You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2020/01/04 19:52:13 UTC

[incubator-superset] 12/22: Math.max(...array) considered harmful (#8575)

This is an automated email from the ASF dual-hosted git repository.

villebro pushed a commit to branch 0.35
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 7db52832f226470b70c820d1d2aaf5722f7b7aff
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Thu Nov 14 17:07:18 2019 -0800

    Math.max(...array) considered harmful (#8575)
    
    * Do not use Math.max
    
    * Small fix
---
 superset/assets/src/components/FilterableTable/FilterableTable.jsx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/superset/assets/src/components/FilterableTable/FilterableTable.jsx b/superset/assets/src/components/FilterableTable/FilterableTable.jsx
index b8c09ef..3f4b4f4 100644
--- a/superset/assets/src/components/FilterableTable/FilterableTable.jsx
+++ b/superset/assets/src/components/FilterableTable/FilterableTable.jsx
@@ -170,10 +170,13 @@ export default class FilterableTable extends PureComponent {
     ).map(dimension => dimension.width);
 
     this.props.orderedColumnKeys.forEach((key, index) => {
-      widthsByColumnKey[key] = Math.max(...colWidths.slice(
+      // we can't use Math.max(...colWidths.slice(...)) here since the number
+      // of elements might be bigger than the number of allowed arguments in a
+      // Javascript function
+      widthsByColumnKey[key] = colWidths.slice(
         index * (this.list.size + 1),
         (index + 1) * (this.list.size + 1),
-      )) + PADDING;
+      ).reduce((a, b) => Math.max(a, b)) + PADDING;
     });
 
     return widthsByColumnKey;