Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Ionic-1.0.0-rc.0 - Cannot call method "contains" of undefined #3295

Closed
revie opened this issue Mar 11, 2015 · 4 comments
Closed

bug: Ionic-1.0.0-rc.0 - Cannot call method "contains" of undefined #3295

revie opened this issue Mar 11, 2015 · 4 comments

Comments

@revie
Copy link

revie commented Mar 11, 2015

Type: bug

Platform: android 4.0 webview

I'm getting a javascript error when testing some animation code on an Android 4.0.3 tablet, which says:

Uncaught TypeError: Cannot call method 'contains' of undefined at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:3162

which points to the following line in ionic.requestAnimationFrame():

if (ele.classList.contains('button')) {

Line needs to be changed to the following, to avoid the error:

if (ele.classList && ele.classList.contains('button')) {

Also recommend making the same changes to the classList checks a few lines before and a few lines after the line mentioned to avoid running into the error when checking for class entries of "item" or "pane" as well.

@revie revie changed the title Bug: Ionic-1.0.0-rc.0 - Cannot call method "contains" of undefined bug: Bug: Ionic-1.0.0-rc.0 - Cannot call method "contains" of undefined Mar 11, 2015
@revie revie changed the title bug: Bug: Ionic-1.0.0-rc.0 - Cannot call method "contains" of undefined bug: Ionic-1.0.0-rc.0 - Cannot call method "contains" of undefined Mar 11, 2015
@brayancastrop
Copy link

Hi guys, i think this issue is still there, though it's fixed for a different line to the reported.

I'm having the same issue with this line
file:///android_asset/www/lib/ionic/js/ionic.bundle.js: Line 3177 : Uncaught TypeError: Cannot call method contains' of undefined

if (ele.classList.contains('button')) {

and as @revie mentioned, just need a small change to

if (ele.classList && ele.classList.contains('button')) {

not sure why was fixed for the other line as suggested and not for the reported one.

@rajavijin
Copy link

Guys i also get the error. In our ionic version 1.0.0 uranium. change as brayancastrop suggests can fix the issue.

@dpalou
Copy link

dpalou commented Sep 8, 2015

Hi,

This error happens sometimes in our app using Ionic 1.0.1. It happens at the line 23 of the minified version. I looked at it and I found 2 possible candidates:

1- Line 3179 of ionic.bundle.js version 1.1.0

if (ele.classList.contains('button')) {  

2- Line 5046 of ionic.bundle.js version 1.1.0

var isModal = container.parentNode.classList.contains('modal');

Hope this helps!

@revie
Copy link
Author

revie commented Sep 8, 2015

Thanks @dpaloucva. In addition to your two, it looks like there's another one that is just like your #2, but on line 7189 in ionic.bundle.js v1.1.0:

var isModal = container.parentNode.classList.contains('modal');

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants