bootstrap-switch
bootstrap-switch copied to clipboard
Class definitions not created on outer div
for version 3.3.5 The class assignments on the outer div do not work. The classes are "bootstrap-switch-undefined bootstrap-switch-undefined bootstrap-switch-undefined bootstrap-switch-undefined bootstrap-switch-undefined bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-animate" It, therefore, does not honour the size assignment.
On inspection v.3.3.4 (as used by the Codepen) does seem to assign the classes correctly
I have the same problem with incorrect classes for wrapper, Bootstrap Switch, version v3.3.4. Very strange, I don't understand what caused it...
您好,您的来信已收到。 祝好 致礼!
Same problem exists in v3.4.0.
It is caused by https://github.com/Bttstrp/bootstrap-switch/blob/2b316be8001254ef9f6e229144b625c4674560cb/src/js/bootstrap-switch.js#L15
The filter is wrong. I believe it should be
return [
state ? 'on' : 'off',
size,
disabled ? 'disabled' : undefined,
readonly ? 'readonly' : undefined,
indeterminate ? 'indeterminate' : undefined,
inverse ? 'inverse' : undefined,
id ? `id-${id}` : undefined,
].filter(v => v != null);
or, to be more coherent with the values in the array:
return [
state ? 'on' : 'off',
size,
disabled ? 'disabled' : undefined,
readonly ? 'readonly' : undefined,
indeterminate ? 'indeterminate' : undefined,
inverse ? 'inverse' : undefined,
id ? `id-${id}` : undefined,
].filter(v => v != undefined);
But you certainly don't want to apply a filter to keep undefined values.
您好,您的来信已收到。 祝好 致礼!