|
27 | 27 | return -1;
|
28 | 28 | };
|
29 | 29 | }
|
30 |
| - // ie8 wat |
31 |
| - if (!Function.prototype.bind) { |
32 |
| - Function.prototype.bind = function(oThis) { |
33 |
| - if (typeof this !== 'function') { |
34 |
| - // closest thing possible to the ECMAScript 5 |
35 |
| - // internal IsCallable function |
36 |
| - throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); |
37 |
| - } |
38 |
| - |
39 |
| - var aArgs = arraySlice.call(arguments, 1), |
40 |
| - fToBind = this, |
41 |
| - FNOP = function() {}, |
42 |
| - fBound = function() { |
43 |
| - return fToBind.apply(this instanceof FNOP && oThis ? this : oThis, aArgs.concat(arraySlice.call(arguments))); |
44 |
| - }; |
45 |
| - |
46 |
| - FNOP.prototype = this.prototype; |
47 |
| - fBound.prototype = new FNOP(); |
48 |
| - |
49 |
| - return fBound; |
50 |
| - }; |
51 |
| - } |
52 | 30 |
|
53 | 31 | // $WebSocketProvider.$inject = ['$rootScope', '$q', '$timeout', '$websocketBackend'];
|
54 | 32 | function $WebSocketProvider($rootScope, $q, $timeout, $websocketBackend) {
|
|
127 | 105 | $WebSocket.prototype._connect = function _connect(force) {
|
128 | 106 | if (force || !this.socket || this.socket.readyState !== this._readyStateConstants.OPEN) {
|
129 | 107 | this.socket = $websocketBackend.create(this.url, this.protocols);
|
130 |
| - this.socket.onmessage = this._onMessageHandler.bind(this); |
131 |
| - this.socket.onopen = this._onOpenHandler.bind(this); |
132 |
| - this.socket.onerror = this._onErrorHandler.bind(this); |
133 |
| - this.socket.onclose = this._onCloseHandler.bind(this); |
| 108 | + this.socket.onmessage = angular.bind(this, this._onMessageHandler); |
| 109 | + this.socket.onopen = angular.bind(this, this._onOpenHandler); |
| 110 | + this.socket.onerror = angular.bind(this, this._onErrorHandler); |
| 111 | + this.socket.onclose = angular.bind(this, this._onCloseHandler); |
134 | 112 | }
|
135 | 113 | };
|
136 | 114 |
|
|
293 | 271 | $WebSocket.prototype.reconnect = function reconnect() {
|
294 | 272 | this.close();
|
295 | 273 |
|
296 |
| - $timeout(this._connect.bind(this), this._getBackoffDelay(++this._reconnectAttempts)); |
| 274 | + $timeout(angular.bind(this, this._connect), this._getBackoffDelay(++this._reconnectAttempts)); |
297 | 275 |
|
298 | 276 | return this;
|
299 | 277 | };
|
|
0 commit comments