javascript - IE11 emulation mode emulating ie8 does't recognize indexOf polyfill -


i trying emulate ie8 in ie11 validate code changes have made. how ever there seems problem in emulator prevents me working it.

when called jquery pollyfilled method.

[].indexof(1) 

i error emulator stating following.

the property or method indexof not supported object

this error occurs in emulator. see no problems when trying on real ie8 browser. jquery loaded in both instances , loaded ahead of other javascript code.

does 1 know how emulator behave in same way real browser?

works expected. tested example bellow. there's problem in code. easier if you'd provide code testing purposes.

// production steps of ecma-262, edition 5, 15.4.4.14  // reference: http://es5.github.io/#x15.4.4.14  if (!array.prototype.indexof) {    array.prototype.indexof = function(searchelement, fromindex) {        var k;        // 1. let o result of calling toobject passing      //    value argument.      if (this == null) {        throw new typeerror('"this" null or not defined');      }        var o = object(this);        // 2. let lenvalue result of calling      //    internal method of o argument "length".      // 3. let len touint32(lenvalue).      var len = o.length >>> 0;        // 4. if len 0, return -1.      if (len === 0) {        return -1;      }        // 5. if argument fromindex passed let n      //    tointeger(fromindex); else let n 0.      var n = +fromindex || 0;        if (math.abs(n) === infinity) {        n = 0;      }        // 6. if n >= len, return -1.      if (n >= len) {        return -1;      }        // 7. if n >= 0, let k n.      // 8. else, n<0, let k len - abs(n).      //    if k less 0, let k 0.      k = math.max(n >= 0 ? n : len - math.abs(n), 0);        // 9. repeat, while k < len      while (k < len) {        // a. let pk tostring(k).        //   implicit lhs operands of in operator        // b. let kpresent result of calling        //    hasproperty internal method of o argument pk.        //   step can combined c        // c. if kpresent true,        //    i.  let elementk result of calling        //        internal method of o argument tostring(k).        //   ii.  let same result of applying        //        strict equality comparison algorithm        //        searchelement , elementk.        //  iii.  if same true, return k.        if (k in o && o[k] === searchelement) {          return k;        }        k++;      }      return -1;    };  }    console.log([].indexof(1));


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -