git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 85f7c3ade0ebc8c21a6734cf20824c455a7e572b

Include Function.bind polyfill to workaround bug in V8

Alex Beregszaszi committed on 8/3/2016, 6:18:55 PM
Parent: 95835c54ae0cd7585237f3cf3b929867e8a016b9

Files changed

interface.jschanged
interface.jsView
@@ -409,4 +409,34 @@
409409 const address = new Uint8Array(MOD.exports.memory, addressOffset, constants.ADD_SIZE_BYTES)
410410 this.environment.suicideAddress = address
411411 }
412412 }
413+
414+//
415+// Polyfill required unless this is sorted: https://bugs.chromium.org/p/chromium/issues/detail?id=633895
416+//
417+// Polyfill from: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_objects/Function/bind
418+//
419+Function.prototype.bind = function (oThis) { // eslint-disable-line
420+ if (typeof this !== 'function') {
421+ // closest thing possible to the ECMAScript 5
422+ // internal IsCallable function
423+ throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable')
424+ }
425+
426+ var aArgs = Array.prototype.slice.call(arguments, 1)
427+ var fToBind = this
428+ var fNOP = function () {}
429+ var fBound = function () {
430+ return fToBind.apply(this instanceof fNOP ? this : oThis,
431+ aArgs.concat(Array.prototype.slice.call(arguments)))
432+ }
433+
434+ if (this.prototype) {
435+ // Function.prototype doesn't have a prototype property
436+ fNOP.prototype = this.prototype
437+ }
438+
439+ fBound.prototype = new fNOP() // eslint-disable-line new-cap
440+
441+ return fBound
442+}

Built with git-ssb-web