Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Fatal TypeError 1.13.0: Cant update from 1.12.4 to 1.13.0 #47

Closed
mikeploeger opened this issue Apr 20, 2018 · 16 comments
Closed

Fatal TypeError 1.13.0: Cant update from 1.12.4 to 1.13.0 #47

mikeploeger opened this issue Apr 20, 2018 · 16 comments
Assignees
Labels

Comments

@mikeploeger
Copy link

mikeploeger commented Apr 20, 2018

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.

@caseyjhol caseyjhol self-assigned this Apr 20, 2018
@caseyjhol
Copy link
Member

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?

@mikeploeger
Copy link
Author

mikeploeger commented Apr 20, 2018

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.

@caseyjhol
Copy link
Member

Are you sure you're loading Bootstrap before bootstrap-select?

@mikeploeger
Copy link
Author

mikeploeger commented Apr 20, 2018

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.

@caseyjhol
Copy link
Member

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?

@jkrehm
Copy link
Contributor

jkrehm commented Apr 20, 2018

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.

@caseyjhol
Copy link
Member

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.

@mikeploeger
Copy link
Author

mikeploeger commented Apr 20, 2018

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.

@mikeploeger
Copy link
Author

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

@caseyjhol
Copy link
Member

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?

@mikeploeger
Copy link
Author

mikeploeger commented Apr 21, 2018

In the end I removed the dropdownjs library from my project.
I appreciate your fast help, thanks @caseyjhol!

@caseyjhol
Copy link
Member

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.

caseyjhol added a commit that referenced this issue Apr 23, 2018
@caseyjhol
Copy link
Member

Fixed and released in v1.13.1!

@ataft
Copy link

ataft commented Apr 24, 2018

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...

@thekiharani-dev
Copy link

thekiharani-dev commented Jun 9, 2018

1.13.1 is not working on the first click after web page loads in bootstrap 4.1.1, what could be the issue?

@prateekkathal
Copy link

@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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants