Skip to content

Commit

Permalink
rename vars
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-gribanov committed Dec 13, 2018
1 parent d336b63 commit 1845891
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
}
}(this, function () {

const registeredControls = [];
/**
* @type {Object.<string, Function>}
*/
const registry = [];

class Controller {
/**
Expand All @@ -34,7 +37,7 @@
*/
static registerControl(name, control) {
if (typeof control === 'function') {
registeredControls[name] = control;
registry[name] = control;

return true;
}
Expand Down Expand Up @@ -70,13 +73,13 @@
}

// separate the control names by ' ' or ','
const names = element.getAttribute('data-control').replace(/[, ]+/g, ' ').split(' ');
const control_names = element.getAttribute('data-control').replace(/[, ]+/g, ' ').split(' ');

let binded = false;
// find control by name
for (let i = 0; i < names.length; i++) {
if (typeof registeredControls[names[i]] === 'function') {
registeredControls[names[i]](element);
for (let i = 0; i < control_names.length; i++) {
if (typeof registry[control_names[i]] === 'function') {
registry[control_names[i]](element);
binded = true;
}
}
Expand Down

0 comments on commit 1845891

Please sign in to comment.