I'm trying to identify if the string start with dot, hashtag or none, but i'm doing something wrong, i believe.
Selector.match = {
'id' : new RegExp('^#(' + identifier + ')' ),
'class' : new RegExp('^\\.(' + identifier + ')' ),
'tag' : new RegExp('^(' + identifier + '|[*])' ),
};
if (Selector.match['id'].exec(this.selector)) {
console.log('ID');
this.result.push(document.getElementById(this.selector));
} else if (Selector.match['id'].exec(this.selector)) {
this.result.push(document.getElementsByClassName(this.selector));
} else if (Selector.match['tag'].exec(this.selector)) {
this.result.push(document.getElementsByTagName(this.selector));
}
I'm trying to 'emulate' the way that jquery get elements, but is not working because identifier doesn't exist.
Thanks.