javascript - Safari ReferenceError: Can't find variable: Set -


i getting safari referenceerror: can't find variable: set error safari browser. have checked other browsers didn't error codes working fine me.

is can me here wrong here , solution work code browsers?

full demo

problem line

 var charactersx = new set([       0,       32, // space       13 // enter       // add other punctuation symbols or keys    ]);   // convert characters charcode    function tocharcodex(char) {       return char.charcodeat(0);    }     var forbiddencharactersx = new set([       tocharcodex("_"),       tocharcodex("-"),       tocharcodex("?"),       tocharcodex("*"),       tocharcodex("\\"),       tocharcodex("/"),       tocharcodex("("),       tocharcodex(")"),       tocharcodex("="),       tocharcodex("&"),       tocharcodex("%"),       tocharcodex("+"),       tocharcodex("^"),       tocharcodex("#"),       tocharcodex("'"),       tocharcodex("<"),       tocharcodex("|"),       tocharcodex(">"),       tocharcodex("."),       tocharcodex(","),       tocharcodex(";")    ]); 

use arrays instead

var charactersx = [   0,   32, // space   13 // enter   // add other punctuation symbols or keys ]; 

and replace .has(), e.g. here:

if (charactersx.has(code)) 

with

if (charactersx.indexof(code) > -1)  

and

if (forbiddencharactersx.has(code)) 

with indexof > -1 too...


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -