Fatal TypeError 1.13.0: Cant update from 1.12.4 to 1.13.0
Closed this issue · 16 comments
1.12.4 is working perfectly.
1.13.0 doesnt work at all.
Steps to reproduce:
Update from 1.12.4 to 1.13.0 through bower:
bower update bootstrap-select
First Bug: Invalid meta desctiption of 1.13.0 (1.12.4 doesnt have this bug)
bower not-cached https://github.com/snapappointments/bootstrap-select.git#^1.13.0
bower resolve https://github.com/snapappointments/bootstrap-select.git#^1.13.0
bower download https://github.com/snapappointments/bootstrap-select/archive/v1.13.0.tar.gz
bower extract bootstrap-select#^1.13.0 archive.tar.gz
bower invalid-meta for:/var/folders/z1/5vz7njdx5qj2zjktbtgf81xm0000gn/T/username/bower/c225966f7f5f71e5c9bdec3a4c8b6550-73520-McjZ31/bower.json
bower invalid-meta The "description" is too long, the limit is 140 characters
bower resolved https://github.com/snapappointments/bootstrap-select.git#1.13.0
bower install bootstrap-select#1.13.0
Second Bug: Cant run 1.13.0 at all, because I get this error message:
TypeError: undefined is not an object (evaluating 't.fn.dropdown.Constructor.VERSION')
The error redirects me to the line:
b.full = (t.fn.dropdown.Constructor.VERSION || "").split(" ")[0].split("."), b.major = b.full[0];
Iam using Safari 11.1 on MacOS, Bootstrap 3.3.7, jQuery 2.2.4 and inserting the script through vendor.json:
"bower_components/bootstrap-select/dist/js/bootstrap-select.min.js",
Any thought on the second bug?
The whole plugin doesnt work without fixing it.
The bower description bug will be fixed in v1.13.1. Working on recreating the second bug. Are you getting that in any other browsers, or just Safari?
Yeah the same for Firefox 59.0.2 (TypeError: t.fn.dropdown.Constructor is undefined) + Chrome 65 (Uncaught TypeError: Cannot read property 'VERSION' of undefined)
If it helps, I could try code changes, if you have any suggestions.
Are you sure you're loading Bootstrap before bootstrap-select?
Maybe helpful, Ive tried something:
Old:
version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.');
New:
version.full = ('1.13.0' || '').split(' ')[0].split('.');
And its working without any errors. Maybe it is possible to rewrite just the $.fn.dropdown.Constructor.VERSION in another way?
And yes, i'am loading it as last library.
That line of code retrieves the Bootstrap version. If Constructor is returning undefined, it has to be an issue with the way Bootstrap is being implemented. Could you link me to a demo?
I ran into this issue while using bootstrap-select in a React environment (no delivered Bootstrap code). We've been using bootstrap-select without issue that way until v1.13.0. I've pinned it to never go beyond 1.12.4 to resolve the issue.
I recognize that bootstrap-select has Bootstrap right in its name, but up to this point I'm unaware of dependencies between bootstrap-select and Bootstrap's JS. I've not run into any, at least.
Bootstrap-select depends on Bootstrap's dropdown.js, as well as some other necessary CSS. I'm planning on releasing a bundled version in the near future that would include only the necessary Bootstrap code to prevent having to load Bootstrap separately (to prevent extra bloat if you're not already using Bootstrap in your project).
I would love to get this particular issue figured out, but I need to find a way to recreate it so I can get to the bottom of it.
Iam more than happy to let you know that I could fix the bug!
Like I said, 1.12.4 worked without an issue before and iam using the dropdown plugin v.3.3.7 which is inside the bootstrap.js file.
To fix the newly introduced 1.13.0 TypeError Bug I had to change the order in which the scripts are embedded inside the vendor.json.
Before (With Error):
"bower_components/bootstrap/dist/js/bootstrap.min.js",
"bower_components/bootstrap/dist/css/bootstrap.min.css",
...
"bower_components/dropdown.js/jquery.dropdown.js",
...
"bower_components/bootstrap-select/dist/js/bootstrap-select.js",
After (Wich fixes the error):
"bower_components/bootstrap/dist/js/bootstrap.min.js",
"bower_components/bootstrap/dist/css/bootstrap.min.css",
...
"bower_components/bootstrap-select/dist/js/bootstrap-select.js",
"bower_components/dropdown.js/jquery.dropdown.js",
...
So its crucual that the Bootstrap-Select.js library will be loaded BEFORE the jquery.dropdown.js library is loaded.
UPDATE
I think this part of jquery.dropdown.js interferes with Bootstrap-Select Plugin:
$.fn.dropdown = function(params) {
if( typeof methods[params] == 'function' ) methodsparams;
if (methods[params]) {
return methods[params].apply(this, Array.prototype.slice.call(arguments,1));
} else if (typeof params === "object" | !params) {
return methods.init.apply(this, arguments);
} else {
$.error("Method " + params + " does not exists on jQuery.dropdown");
}
};
And after visiting the Github Repo i found that this is a bug of the jQuery.dropdown.js Plugin:
FezVrasta/dropdown.js#19
Ah, I see. I haven't heard of the dropdown plugin before. It was definitely interfering with Bootstrap's own dropdown.js. Is there a reason you're including both?
In the end I removed the dropdownjs library from my project.
I appreciate your fast help, thanks @caseyjhol!
I'll go ahead and make a change in v1.13.1, so that if there are any issues detecting the version it will fall back to 3.
I ran into this issue as well and 1.13.1 fixed it, but I still get the ugly console.error. Maybe it's better as a console.info until the issue is completely understood and fixed? I'm loading jQuery before Bootstrap so that bootstrap tooltip overrides jQuery's. Then, bootstrap-select is loaded after those. I have these set up as dependencies in a requirejs config...
1.13.1 is not working on the first click after web page loads in bootstrap 4.1.1, what could be the issue?
@caseyjhol Still getting this error (Click Here)
In my packages.json
"devDependencies": {
"axios": "^0.18",
"bootstrap": "^4.1.2",
"browser-sync": "^2.24.4",
"browser-sync-webpack-plugin": "2.0.1",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^2.0",
"lodash": "^4.17.4",
"popper.js": "^1.12",
"vue": "^2.5.7"
},
"dependencies": {
"bootstrap-select": "^1.13.1",
"chart.js": "^2.7.2",
"datatables.net": "^1.10.16",
"datatables.net-bs4": "^1.10.16",
"font-awesome": "^4.7.0",
"gijgo": "^1.9.6"
}
I went inside the bootstrap-select.js and it still has the old code (Check Here)
Why can't I find this commit in 1.13.1? When are you planning to merge this?