diff --git a/src/bootstrap-table.js b/src/bootstrap-table.js index 39e2339f4..ccc8714af 100644 --- a/src/bootstrap-table.js +++ b/src/bootstrap-table.js @@ -2587,6 +2587,11 @@ class BootstrapTable { const row = this.data[params.index] const originalIndex = this.options.data.indexOf(row) + if (originalIndex === -1) { + this.append([params.row]) + return + } + this.data.splice(params.index, 0, params.row) this.options.data.splice(originalIndex, 0, params.row) this.initSearch() diff --git a/src/utils/index.js b/src/utils/index.js index e7c6ff8ce..5a7752597 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -2,27 +2,20 @@ export default { getBootstrapVersion () { let bootstrapVersion = 5 - try { - const rawVersion = $.fn.dropdown.Constructor.VERSION + if (typeof window !== 'undefined' && window.bootstrap?.Tooltip?.VERSION) { + const rawVersion = window.bootstrap.Tooltip.VERSION - // Only try to parse VERSION if it is defined. - // It is undefined in older versions of Bootstrap (tested with 3.1.1). if (rawVersion !== undefined) { bootstrapVersion = parseInt(rawVersion, 10) } - } catch (e) { - console.error(e) - } - - try { - // eslint-disable-next-line no-undef - const rawVersion = bootstrap.Tooltip.VERSION + } else if (typeof $ !== 'undefined' && $.fn?.dropdown?.Constructor?.VERSION) { + const rawVersion = $.fn.dropdown.Constructor.VERSION + // Only try to parse VERSION if it is defined. + // It is undefined in older versions of Bootstrap (tested with 3.1.1). if (rawVersion !== undefined) { bootstrapVersion = parseInt(rawVersion, 10) } - } catch (e) { - console.error(e) } return bootstrapVersion