contactlab / contactlab-ui-components

DEPRECATED - Basic UI components for ContactLab UX design pattern library
http://contactlab.github.io/contactlab-pattern-library
Apache License 2.0
30 stars 8 forks source link

<pagination-clab> "tot" and "current-page" parameters must be number #139

Closed DarkHelmet67 closed 7 years ago

DarkHelmet67 commented 7 years ago

In <pagination-clab> if "tot" and "current-page" parameters are passed as strings (e.g. "10" and "1" instead of 10 and 1) all calculations with additions will fail because "+" is treated as "string concatenation operator" and not "sum operator"

Example:

_getEnd(c, pages) {
    let last = pages.length - 1;
    if(c >= last - (this.range / 2)) {
      return last;
    } else if(c <= (this.range / 2)) {
      return this.range;
    } else {
      return c + (this.range / 2);
    }
  }

If c=5 and this.range=8 last row will return 5 + (8 / 2) = 9. If c="5" and this.range=8 last row will return "5" + (8 / 2) = "54".