Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookie Extension - this.options undefined by customStorage #7707

Open
StefanTD opened this issue Jan 31, 2025 · 2 comments
Open

Cookie Extension - this.options undefined by customStorage #7707

StefanTD opened this issue Jan 31, 2025 · 2 comments
Labels
Bug Issues which are marked as Bug

Comments

@StefanTD
Copy link

Bootstraptable version(s) affected

1.24.0

Description

When using the extension cookie, an error “this.options is undefined” is reported for 'customStorage' when building the table and when calling “this._storage.getItem”.

Example(s)

this._storage.getItem = function (cookieName) {
return Utils.calculateObjectValue(this.options, this.options.cookieCustomStorageGet, [cookieName], '')
}

Possible Solutions

No response

Additional Context

No response

@StefanTD StefanTD added the Bug Issues which are marked as Bug label Jan 31, 2025
@dfmaxwell
Copy link

dfmaxwell commented Feb 10, 2025

I have this issue too.

I see a variable "that" in 1.21.4 and this code and the counterpart does not seem to be in 1.24.0. I'm wondering if this is just a simple fix. I'm not sure how to handle a change here that can be reviewed and such outside of what I see and put here in a comment.

I see this in 1.21.4
key: "configureStorage",
value: function configureStorage() {
var that = this;
this._storage = {};
switch (this.options.cookieStorage) {
case 'cookieStorage':
this._storage.setItem = function (cookieName, cookieValue) {
document.cookie = [cookieName, '=', encodeURIComponent(cookieValue), "; expires=".concat(UtilsCookie.calculateExpiration(that.options.cookieExpire)), that.options.cookiePath ? "; path=".concat(that.options.cookiePath) : '', that.options.cookieDomain ? "; domain=".concat(that.options.cookieDomain) : '', that.options.cookieSecure ? '; secure' : '', ";SameSite=".concat(that.options.cookieSameSite)].join('');
};

I see this in 1.24.0
key: "configureStorage",
value: function configureStorage() {
this._storage = {};
switch (this.options.cookieStorage) {
case 'cookieStorage':
this._storage.setItem = function (cookieName, cookieValue) {
document.cookie = [cookieName, '=', encodeURIComponent(cookieValue), "; expires=".concat(UtilsCookie.calculateExpiration(this.options.cookieExpire)), this.options.cookiePath ? "; path=".concat(this.options.cookiePath) : '', this.options.cookieDomain ? "; domain=".concat(this.options.cookieDomain) : '', this.options.cookieSecure ? '; secure' : '', ";SameSite=".concat(this.options.cookieSameSite)].join('');
};

@roddypratt
Copy link

I think this is a duplicate of #7670

My workaround was to use localStorage rather than cookieStorage in the table options.

cookieStorage: "localStorage"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues which are marked as Bug
Projects
None yet
Development

No branches or pull requests

3 participants