bootstrap-vue: b-form-checkbox assign is not a function
Describe the bug
in Vue 3 + vue-compat. When setting v-model on a b-form-checkbox component results in a runtime error when clicking the switch. Does not occur with a standard input field.
Steps to reproduce the bug
- use b-form-checkbox in a view or component
- set v-model to a boolean property
- click switch/checkbox
- Error
Expected behavior
No runtime Error.
Versions
Libraries:
- BootstrapVue: 2.23.1
- Bootstrap: 4.6.2
- Vue: 3.3.7
Environment:
- Device: Macbook Pro
- OS: MacOS Sonoma 14.0
- Browser: Chrome
- Version: Version 118.0.5993.117 (Official Build) (arm64)
Demo link
minimal repro on stackblitz
https://stackblitz.com/edit/bootstrap-vue-with-compat-fsfglw?file=components%2FHelloBootstrap.vue
Additional context
in my application, this crashes UI with ‘Uncaught runtime Errors’… in the stackblitz demo, only logs error to console.
When I debug down into the vue.js code, it seems that this call…
const vModelCheckbox = {
...
const assign = el[assignKey]; //yields undefined
....
assign(getCheckboxValue(el, checked)); //assign is not a function as it is undefined (boom)
where: assignKey is Symbol(_assign), this yields undefined, creating the error later
It may be related to this (https://github.com/vuejs/core/pull/4121)
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 8
- Comments: 21
Commits related to this issue
- chore(compat) assign hack needs to use symbol #7181, #7182 — committed to JavascriptMick/bootstrap-vue by MichaelDausmann 3 years ago
- #2490: downloaded to vue 3.3.4 to avoid this bug https://github.com/bootstrap-vue/bootstrap-vue/issues/7182 — committed to NationalSecurityAgency/skills-service by deleted user 3 years ago
We are seeing this exact error during our upgrade to Vue 3.3.7. In addition, we’re seeing
Uncaught TypeError: el[assignKey] is not a functionwhen changing the selected option in a dropdown. If we downgrade to 3.3.4 the error is not thrown.I think I just found a workaround for the issue. Since the checkbox makes use of the
formRadioCheckMixinyou can add this inside therender()inform-radio-check.js. You would have to use your own fork, or you can use mine.Furthermore, for radio inputs you can add this after the initialisation of
$input:EDIT: this might not work in all cases
@helenezspeer You need to make sure that you are not using ^3.3.4 but rather 3.3.4 and the same thing for
@vue/compatI’m getting this same error using Vue 3.3.4.
There is a similar problem with vue-compat / bootstrap-vue and the SELECT input component.
I wish there was a workaround, since I can’t go back to Vue 3.3.4 due to other library constraints.
fwiw, my workaround for now is to replace b-form-checkbox with…