Bootstrap-select: hasOwnProperty error with jQuery 3.5.0

Created on 11 Apr 2020  路  12Comments  路  Source: snapappointments/bootstrap-select

When using new jQuery 3.5.0 there is an error with missing hasOwnProperty() function for data attributes used here:

https://github.com/snapappointments/bootstrap-select/blob/a5b075219d3a87336c046a5a0403023eed8f4c6e/js/bootstrap-select.js#L3083

Probably the root problem is the fix for this issue in jQuery:
https://github.com/jquery/jquery/issues/3256

Most helpful comment

same here.
with jquery 3.4.1 works like a charm, with jquery 3.5.0 got the error

Uncaught TypeError: options.hasOwnProperty is not a function

All 12 comments

Same problem here

same here.
with jquery 3.4.1 works like a charm, with jquery 3.5.0 got the error

Uncaught TypeError: options.hasOwnProperty is not a function

Facing the same issue. With jQuery 3.5.0:

ERROR TypeError: dataAttributes.hasOwnProperty is not a function
    at HTMLSelectElement.<anonymous> (bootstrap-select.js:3080)
    at Function.each (jquery.min.js:2)
    at S.fn.init.each (jquery.min.js:2)
    at S.fn.init.Plugin [as selectpicker] (bootstrap-select.js:3070)
    at EditCompanyComponent.refreshSelect (edit-company.component.ts:42)
    at HTMLDocument.<anonymous> (edit-company.component.ts:27)
    at e (jquery.min.js:2)
    at t (jquery.min.js:2)
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at Object.onInvokeTask (core.js:41442)

same here.
with jquery 3.4.1 works like a charm, with jquery 3.5.0 got the error

Uncaught TypeError: options.hasOwnProperty is not a function

I fix it in angular changing the jquery version:
"jquery": "^3.4.1" to "jquery": "3.4.1"

Looks like our best bet (for now) might be to wait for jQuery v3.5.1 for this to get resolved. This issue will probably get reintroduced in jQuery v4.0.0, but I'm hoping we won't need jQuery as a dependency by then.

At this moment (for who wants), it can be solved by altering the code of the bootstrap-select plugin:

Object.prototype.hasOwnProperty.call(options, i)
instead of
options.hasOwnProperty(i)

It can be considered a valid correction afterall because it much safer.

The fix suggested by @didaxRedux will be a part of the next release. Thanks @didaxRedux!

Released in v1.13.15!

Safer way to hasOwnProperty which would have bypassed this issue:

if (Object.prototype.hasOwnProperty.call(dataAttributes, dataAttr) ...

@mryellow Yes, that is the fix we implemented.

same here.
with jquery 3.4.1 works like a charm, with jquery 3.5.0 got the error
Uncaught TypeError: options.hasOwnProperty is not a function

I fix it in angular changing the jquery version:
"jquery": "^3.4.1" to "jquery": "3.4.1"

Yes this is very strange cause everything was working very well with 3.5 and suddenly i got rhe same error few minutes ago. As you said i downgrade my jquery version to 3.4.1 and i m back to business but that's really strange. Because i haven't update anything. Just suddenly the hasOwnProperty error 馃拃. If i found the reason i ll put that here

=> my version is => "bootstrap-select": "1.13.16", && "jquery": "^3.4.1",

same here.
with jquery 3.4.1 works like a charm, with jquery 3.5.0 got the error
Uncaught TypeError: options.hasOwnProperty is not a function

I fix it in angular changing the jquery version:
"jquery": "^3.4.1" to "jquery": "3.4.1"

Yes this is very strange cause everything was working very well with 3.5 and suddenly i got rhe same error few minutes ago. As you said i downgrade my jquery version to 3.4.1 and i m back to business but that's really strange. Because i haven't update anything. Just suddenly the hasOwnProperty error . If i found the reason i ll put that here

=> my version is => "bootstrap-select": "1.13.16", && "jquery": "^3.4.1",

right now just update to 1.13.17 and you don't get error anymore.
work fine with jQuery 3.5.0 too

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yCodeTech picture yCodeTech  路  3Comments

EmilMoe picture EmilMoe  路  4Comments

qiyuan4f picture qiyuan4f  路  4Comments

Cruyjun picture Cruyjun  路  3Comments

dacavcosta picture dacavcosta  路  3Comments