I made a custom class in Javascript, and although it works perfectly fine on Safari and Chrome in Mac OS, it gives me in error on my iPad.
I'm debugging through the Develop menu on Safari to get the error. What's weird, is that there are no results online I can find out more about it. The error is "Unexpected use of reserved word 'class'".
My JS:
class LoadingIndicator{ // error is here
constructor(elementID){
this.tick = 8;
this.waitStatus = document.getElementById(elementID);
this.animateLoaderVar = setInterval(
this.animateLoader.bind(this),
10
)
}
animateLoader (){
if(this.tick == 8){
this.waitStatus.firstElementChild.innerHTML = ".";
}
else if(this.tick == 16){
this.waitStatus.firstElementChild.innerHTML = "..";
}else if(this.tick == 24){
this.waitStatus.firstElementChild.innerHTML = "...";
this.tick = 0;
}
this.tick += 1;
}
removeLoader(){
this.waitStatus.outerHTML = "";
delete this.waitStatus;
clearInterval(this.animateLoaderVar);
}
}
Class is part of ES6, so it looks like it's not supported within the browser on ios that you're using. What version of iOS is your iPad using?
Also here it is stated that class declarations run in stricte mode: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes
You might have to use 'use strict';
or if it's still not helping there is https://babeljs.io/