From 106dcf889104f026473bb0a5ee40eed9d3456b9a Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Sat, 26 Aug 2017 06:32:57 +0200 Subject: Optimization: Some anonymous callback functions has been simplified with arrow functions which were introduced in ECMAScript 6 (2015). --- static/bigpipe.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'static/bigpipe.js') diff --git a/static/bigpipe.js b/static/bigpipe.js index 30511ea..b101f6a 100755 --- a/static/bigpipe.js +++ b/static/bigpipe.js @@ -99,10 +99,10 @@ BigPipe = (function() { return false; } - let callback = function() { + const callback = () => { PhaseDoneJS.handler(this, Resource.PHASE_DONE); this.executeCallbacks(); - }.bind(this); + }; this.node.onload = callback; this.node.onerror = callback; @@ -157,13 +157,13 @@ BigPipe = (function() { // Pagelet: Initialize the pagelet resources //============================================================================== Pagelet.prototype.initializeResources = function() { - this.stylesheets.forEach(function(data) { + this.stylesheets.forEach(data => { this.attachResource(new Resource(data, Resource.TYPE_STYLESHEET)); - }.bind(this)); + }); - this.javascripts.forEach(function(data) { + this.javascripts.forEach(data => { this.attachResource(new Resource(data, Resource.TYPE_JAVASCRIPT)); - }.bind(this)); + }); }; //============================================================================== @@ -175,7 +175,7 @@ BigPipe = (function() { this.resources[type].forEach(function(resource) { somethingExecuted = true; resource.execute(); - }.bind(this)); + }); return somethingExecuted; }; @@ -197,11 +197,11 @@ BigPipe = (function() { Pagelet.prototype.attachResource = function(resource) { switch(resource.type) { case Resource.TYPE_STYLESHEET: - resource.registerCallback(this.onloadCSS.bind(this)); + resource.registerCallback(() => this.onloadCSS()); break; case Resource.TYPE_JAVASCRIPT: - resource.registerCallback(this.onloadJS.bind(this)); + resource.registerCallback(() => this.onloadJS()); break; } -- cgit v1.2.3