Skip to content

Commit

Permalink
fix more warnings (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
sritchie authored Mar 4, 2022
1 parent d08bb16 commit 195b7e2
Show file tree
Hide file tree
Showing 23 changed files with 256 additions and 256 deletions.
4 changes: 2 additions & 2 deletions src/api.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export class Api {
static apply(object) {
object.set = function (options) {
var o = this.options || {};
const o = this.options || {};

// Diff out changes
var changes = Object.entries(options).reduce(function (
const changes = Object.entries(options).reduce(function (
result,
[key, value]
) {
Expand Down
26 changes: 13 additions & 13 deletions src/binder.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ export class Binder {
}

// Set base target
var fallback = context;
let fallback = context;

if (Array.isArray(key)) {
fallback = key[0];
key = key[1];
}

// Match key
var match = /^([^.:]*(?:\.[^.:]+)*)?(?::(.*))?$/.exec(key);
var path = match[1].split(/\./g);
const match = /^([^.:]*(?:\.[^.:]+)*)?(?::(.*))?$/.exec(key);
const path = match[1].split(/\./g);

var name = path.pop();
var dest = match[2] || name;
const name = path.pop();
const dest = match[2] || name;

// Whitelisted objects
var selector = path.shift();
const selector = path.shift();

var target =
let target =
{
this: object,
}[selector] ||
Expand All @@ -41,7 +41,7 @@ export class Binder {

// Attach event handler at last level
if (target && (target.on || target.addEventListener)) {
var callback = function (event) {
const callback = function (event) {
object[dest] && object[dest](event, context);
};

Expand All @@ -51,7 +51,7 @@ export class Binder {
});

// Store bind for removal later
var bind = { target: target, name: name, callback: callback };
const bind = { target: target, name: name, callback: callback };
object.__binds.push(bind);

// Return callback
Expand Down Expand Up @@ -107,14 +107,14 @@ export class Binder {
static _trigger(event) {
if (this._listeners === undefined) return;

var type = event.type;
var listeners = this._listeners[type];
const type = event.type;
let listeners = this._listeners[type];
if (listeners !== undefined) {
listeners = listeners.slice();
var length = listeners.length;
const length = listeners.length;

event.target = this;
for (var i = 0; i < length; i++) {
for (let i = 0; i < length; i++) {
// add original target as parameter for convenience
listeners[i].call(this, event, this);
}
Expand Down
20 changes: 10 additions & 10 deletions src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class Bootstrap {
}

static registerPlugin(name, spec) {
var ctor = function (options) {
const ctor = function (options) {
Bootstrap.Plugin.call(this, options);
this.__name = name;
};
Expand Down Expand Up @@ -78,7 +78,7 @@ export class Bootstrap {
this.__installed = [];

// Query element
var element = this.__options.element;
let element = this.__options.element;
if (element === "" + element) {
element = document.querySelector(element);
}
Expand Down Expand Up @@ -128,12 +128,12 @@ export class Bootstrap {
plugins = Array.isArray(plugins) ? plugins : [plugins];

// Resolve alias database
var o = this.__options;
var aliases = Object.assign({}, o.aliasdb, o.aliases);
const o = this.__options;
const aliases = Object.assign({}, o.aliasdb, o.aliases);

// Remove inline alias defs from plugins
var pred = function (name) {
var key = name.split(":");
const pred = function (name) {
const key = name.split(":");
if (!key[1]) return true;
aliases[key[0]] = [key[1]];
return false;
Expand All @@ -150,7 +150,7 @@ export class Bootstrap {
if (level >= 256) throw "Plug-in alias recursion detected.";
list = list.filter(pred);
list.forEach(function (name) {
var alias = aliases[name];
const alias = aliases[name];
if (!alias) {
out.push(name);
} else {
Expand Down Expand Up @@ -192,16 +192,16 @@ export class Bootstrap {

__install(name) {
// Sanity check
var ctor = this.__options.plugindb[name];
const ctor = this.__options.plugindb[name];
if (!ctor)
throw "[three.install] Cannot install. '" + name + "' is not registered.";

if (this.plugins[name])
return console.warn("[three.install] " + name + " is already installed.");

// Construct
var Plugin = ctor;
var plugin = new Plugin(this.__options[name] || {}, name);
const Plugin = ctor;
const plugin = new Plugin(this.__options[name] || {}, name);
this.plugins[name] = plugin;

// Install
Expand Down
8 changes: 4 additions & 4 deletions test/api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

describe("api", function () {
it("sends change events", function () {
var captured = {};
var api;
let captured = {};
let api;

var klass = function () {
const klass = function () {
api = this.api({});
};

THREE.Binder.apply(klass.prototype);
THREE.Api.apply(klass.prototype);

var o = new klass();
const o = new klass();
o.on("change", function (event) {
captured = event.changes;
expect(event.changes.foo).toBe(this.options.foo);
Expand Down
20 changes: 10 additions & 10 deletions test/binder.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

describe("binder", function () {
it("binds/unbinds events", function () {
var ready = 0;
var foo = 0;
var wtf = 0;
let ready = 0;
let foo = 0;
let wtf = 0;

var context = {};
const context = {};
THREE.Binder.apply(context);

var object = {
Expand All @@ -32,8 +32,8 @@ describe("binder", function () {
};
THREE.Binder.apply(object);

var bind = THREE.Binder.bind(context, {});
var unbind = THREE.Binder.unbind(context);
const bind = THREE.Binder.bind(context, {});
const unbind = THREE.Binder.unbind(context);

_.each(object.listen, function (key) {
bind(key, object);
Expand Down Expand Up @@ -63,9 +63,9 @@ describe("binder", function () {
});

it("binds/unbinds once events", function () {
var ready = 0;
let ready = 0;

var context = {};
const context = {};
THREE.Binder.apply(context);

var object = {
Expand All @@ -79,8 +79,8 @@ describe("binder", function () {
};
THREE.Binder.apply(object);

var bind = THREE.Binder.bind(context, {});
var unbind = THREE.Binder.unbind(context);
const bind = THREE.Binder.bind(context, {});
const unbind = THREE.Binder.unbind(context);

_.each(object.listen, function (key) {
bind(key, object);
Expand Down
Loading

0 comments on commit 195b7e2

Please sign in to comment.