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

Array.prototype.find visible and enumerable in every array instance #776

Closed
bram2w opened this issue Jun 29, 2016 · 2 comments
Closed

Array.prototype.find visible and enumerable in every array instance #776

bram2w opened this issue Jun 29, 2016 · 2 comments

Comments

@bram2w
Copy link

bram2w commented Jun 29, 2016

Steps for Reproduction

Open this HTML code in IE 11:

<link href="http://cdn.quilljs.com/1.0.0-beta.6/quill.snow.css" rel="stylesheet">

<div id="editor">
  <p>Hello World!</p>
</div>

<script src="http://cdn.quilljs.com/1.0.0-beta.6/quill.min.js"></script>

<script>
    var data = {
        'tmp': [],
    };
    for(var block in data.tmp){
        console.log("test: " + data.tmp[block]);
    }
</script>

<script>
    var editor = new Quill('#editor', {
        theme: 'snow'
    });
</script>

Expected behavior: No console.log message

Actual behavior: console.log message "test: function(predicate){if(this===null){throw ..."

Platforms: IE 11 and PhantomJS

Version: 1.0.0-beta.6

Fix: In file /core/polyfill.js replace. I only tested this by replacing this in the released version.

if (!Array.prototype.find) {
  Array.prototype.find = function(predicate) {
    if (this === null) {
      throw new TypeError('Array.prototype.find called on null or undefined');
    }
    if (typeof predicate !== 'function') {
      throw new TypeError('predicate must be a function');
    }
    var list = Object(this);
    var length = list.length >>> 0;
    var thisArg = arguments[1];
    var value;

    for (var i = 0; i < length; i++) {
      value = list[i];
      if (predicate.call(thisArg, value, i, list)) {
        return value;
      }
    }
    return undefined;
  };
}

with:

if (!Array.prototype.find) {
  Object.defineProperty(Array.prototype, "find", {
    value: function(predicate) {
      if (this === null) {
        throw new TypeError('Array.prototype.find called on null or undefined');
      }
      if (typeof predicate !== 'function') {
        throw new TypeError('predicate must be a function');
      }
      var list = Object(this);
      var length = list.length >>> 0;
      var thisArg = arguments[1];
      var value;

      for (var i = 0; i < length; i++) {
        value = list[i];
        if (predicate.call(thisArg, value, i, list)) {
          return value;
        }
      }
      return undefined;
    };
  });
}
@jhchen
Copy link
Member

jhchen commented Jun 29, 2016

Where are you getting your polyfill code from?

@bram2w
Copy link
Author

bram2w commented Jun 30, 2016

@jhchen jhchen closed this as completed in b779ae4 Jul 7, 2016
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

2 participants