Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype.js #97

Closed
maxiloc opened this issue Sep 17, 2015 · 5 comments
Closed

Prototype.js #97

maxiloc opened this issue Sep 17, 2015 · 5 comments

Comments

@maxiloc
Copy link
Contributor

maxiloc commented Sep 17, 2015

It seems there is a conflict with prototype.js.

This method line return new (_bind.apply(Class, [null].concat(args)))(); fails because it is using the bind method of prototype

@vvo
Copy link
Contributor

vvo commented Sep 17, 2015

Can you point a link where we can reproduce this? I am doing a release right now

@maxiloc
Copy link
Contributor Author

maxiloc commented Sep 17, 2015

I will try to reproduce it outside of magento tomorow

@vvo
Copy link
Contributor

vvo commented Sep 17, 2015

If you can push your magento branch I can test

@redox
Copy link
Contributor

redox commented Sep 21, 2015

So Prototype.js (< 1.7.2) actually replaces the bind method in every cases: prototypejs/prototype@9559d88

@vvo
Copy link
Contributor

vvo commented Sep 21, 2015

For reference, prototype.js:

  1. overwrite .bind in < 1.7.2.
  2. does a bad job with the polyfill (not forwarding .prototype etc).

You can just insert this:

// Magento is using a very old prototype.js version with a poor Function.prototype.bind
// forced overloading, we redefine it here so that our code works
// ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
Function.prototype.bind = function(oThis) {
  if (typeof this !== 'function') {
    // closest thing possible to the ECMAScript 5
    // internal IsCallable function
    throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
  }

  var aArgs   = Array.prototype.slice.call(arguments, 1),
      fToBind = this,
      fNOP    = function() {},
      fBound  = function() {
        return fToBind.apply(this instanceof fNOP
               ? this
               : oThis,
               aArgs.concat(Array.prototype.slice.call(arguments)));
      };

  if (this.prototype) {
    // native functions don't have a prototype
    fNOP.prototype = this.prototype;
  }
  fBound.prototype = new fNOP();

  return fBound;
};

Before inserting instantsearch.js

@vvo vvo closed this as completed Sep 21, 2015
sarahdayan pushed a commit that referenced this issue Dec 12, 2022
* fix(panel): align button and make clearer

fixes #97

* chore: remove headerText
sarahdayan pushed a commit that referenced this issue Dec 14, 2022
* fix(panel): align button and make clearer

fixes #97

* chore: remove headerText
sarahdayan pushed a commit that referenced this issue Dec 14, 2022
…s#98)

* fix(panel): align button and make clearer

fixes #97

* chore: remove headerText
sarahdayan pushed a commit that referenced this issue Dec 14, 2022
…s#98)

* fix(panel): align button and make clearer

fixes #97

* chore: remove headerText
sarahdayan pushed a commit that referenced this issue Dec 15, 2022
…s#98)

* fix(panel): align button and make clearer

fixes #97

* chore: remove headerText
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants