josecebe / twbs-pagination

jQuery pagination plugin (bootstrap powered)
http://josecebe.github.io/twbs-pagination/
Other
1.1k stars 405 forks source link

Some bug about startPage #163

Open ranlix opened 6 years ago

ranlix commented 6 years ago
getPages: function (currentPage) {
            var pages = [];

            var half = Math.floor(this.options.visiblePages / 2);
            var start = currentPage - half + 1 - this.options.visiblePages % 2;
            var end = currentPage + half;
            // handle boundary case
            if (start <= 0) {
                start = 1;
                end = this.options.visiblePages;
            }
            if (end > this.options.totalPages) {
                start = this.options.totalPages - this.options.visiblePages + 1;
                end = this.options.totalPages;
            }

            var itPage = start;
            while (itPage <= end) {
                pages.push(itPage);
                itPage++;
            }

            return {"currentPage": currentPage, "numeric": pages};
        },

in below code block, if currentPage and half have different type(int and string), there will be error, same issue exists in "render" method: if ($this.data('page') === pages.currentPage) ==> if ($this.data('page') === +pages.currentPage)

josecebe commented 6 years ago

In what cases could these variables be different type?