Coder Social home page Coder Social logo

Comments (19)

gnh1201 avatar gnh1201 commented on May 28, 2024 2

Modifying es6-shim to match the changes in es5-shim(sham) corrected the error. Please check if it is a valid solution.

from es5-shim.

gnh1201 avatar gnh1201 commented on May 28, 2024 1

The exact point of failure is that there is a variable called object marked undefined. This depends on whether it is == or === as shown in 64b444e.

  • es5-sham.js:L70
if (proto || proto == null) { // `undefined` is for pre-proto browsers    // <--- allow 'undefined' object
// if (proto || proto === null) //  <--- disallow 'undefined' object
  • es6-shim.js:L72
if (!force && name in object) { return; }    // <--- error and break (because `object' is `undefined`)

If I can see the stack trace, I will write it soon.

from es5-shim.

ljharb avatar ljharb commented on May 28, 2024

I'm afraid I'll need a lot more info than "does not work" :-) I use both es5-shim and es6-shim on a number of projects, so I'm also surprised to hear there's an issue.

Here's the difference between v4.5.15 (which was released 3 months ago) and v4.5.14: v4.5.14...v4.5.15

The only differences that could possibly cause an issue are 64b444e (es5-sham, avoiding an infinite loop in pre-proto browsers) and 0fda3b8 (adding a name to the split replacement), and 9390b33 (caching floor/abs/pow off of Math).

The only thing I can think of is that perhaps es6-shim is patching these Math methods, which affects some of the other things in es5-shim.

from es5-shim.

gnh1201 avatar gnh1201 commented on May 28, 2024

The lines that are currently experiencing errors in es6-shim are as follows. https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L72

  var defineProperty = function (object, name, value, force) {
    if (!force && name in object) { return; }
    if (supportsDescriptors) {
      Object.defineProperty(object, name, {
        configurable: true,
        enumerable: false,
        writable: true,
        value: value
      });
    } else {
      object[name] = value;
    }
  };

I checked the parameters passed. If es5-shim 4.5.15 is used, there is an entry in which the variable 'force' appears as 'undefined'.

* object: object
* name: string
indexOf
* value: function
function indexOf(searchElement) {
      var value = _arrayIndexOfApply(this, arguments);
      if (value === 0 && (1 / value) < 0) {
        return 0;
      }
      return value;
    }
* force: boolean
-1
* object: object
* name: string
_es6-shim iterator_
* value: function
function () { return this.values(); }
* force: undefined

* object: undefined
* name: string
_es6-shim iterator_
* value: function
function iterator() { return this; }
* force: undefined

// error

Based on the results above, there seems to be a problem with _iterator. When I used es5-shim 4.5.14, there were no items marked undefined and everything worked fine.

* object: function                                           
* name: string                                               
toString                                                     
* value: function                                            
function (){ return binder.apply(this, arguments); }         
* force: boolean                                             
-1                                                           
* object: object                                             
* name: string                                               
sup                                                          
* value: function                                            
function sub() { return ES.CreateHTML(this, 'sup', '', ''); }
* force: boolean                                             
-1                                                           
* object: function                                           
* name: string                                               
toString                                                     
* value: function                                            
function (){ return binder.apply(this, arguments); }         
* force: boolean                                             
-1                                                           

// done without error

from es5-shim.

gnh1201 avatar gnh1201 commented on May 28, 2024

Oh! Fixed! I fixed this change back to === and it works fine. 64b444e

from es5-shim.

gnh1201 avatar gnh1201 commented on May 28, 2024

#458

from es5-shim.

ljharb avatar ljharb commented on May 28, 2024

Thanks for clarifying; I’ll try to find a way to test this and avoid the infinite loop.

from es5-shim.

ljharb avatar ljharb commented on May 28, 2024

@gnh1201 in which engines are you experiencing an error? is it when es6-shim is loaded, or when you invoke a specific method?

from es5-shim.

gnh1201 avatar gnh1201 commented on May 28, 2024

The JavaScript engine uses Windows Scripting Host 5.812. There is a problem loading the library.

from es5-shim.

gnh1201 avatar gnh1201 commented on May 28, 2024

Here is the file for the test. https://gist.github.com/gnh1201/3702353d163e549e097c2083b407f8fd

from es5-shim.

gnh1201 avatar gnh1201 commented on May 28, 2024

This is an example of a project being used: https://github.com/gnh1201/welsonjs

from es5-shim.

ljharb avatar ljharb commented on May 28, 2024

ah wow, WSH, that's a name i haven't heard in a long time :-)

I don't have access to any windows machines, so I'm not sure how i can test this. What's the exact failure you get, and on what line (please include the entire stack trace if present), of that gist?

from es5-shim.

ljharb avatar ljharb commented on May 28, 2024

What happens if you leave it as == null, but change the next line to return proto || null;?

from es5-shim.

gnh1201 avatar gnh1201 commented on May 28, 2024

I modified it as below.

  • es5-sham.js:L70
            if (proto || proto == null) { // `undefined` is for pre-proto browsers
                return proto || null;

But the results were the same.

from es5-shim.

gnh1201 avatar gnh1201 commented on May 28, 2024

I'm sorry. There is a difference when I check it again.

  • Before edit
* object: undefined   // <--- here
* name: string
_es6-shim iterator_
* value: function
function iterator() { return this; }
* force: undefined
  • After edit
* object: object   // <--- here
* name: string
_es6-shim iterator_
* value: function
function iterator() { return this; }
* force: undefined

However, the variable force is marked undefined, so the type of error is the same.

from es5-shim.

gnh1201 avatar gnh1201 commented on May 28, 2024

If I change it as below, the error will be solved.

  • es5-sham.js:L70
            if (proto || typeof(proto) !== 'undefined') { // `undefined` is for pre-proto browsers
                return proto;

from es5-shim.

ljharb avatar ljharb commented on May 28, 2024

That change would disallow undefined (reverting 64b444e) but would also allow false, 0, NaN, and 0n.

from es5-shim.

gnh1201 avatar gnh1201 commented on May 28, 2024

So what about proto || typeof(proto) === 'object' instead of proto || typeof(proto) !== 'undefined'?

from es5-shim.

ljharb avatar ljharb commented on May 28, 2024

The previous behavior for that branch was “truthy or null”, and the infinite loop bug fix was to change it to “truthy or null or undefined”. Every suggestion you’ve made reverts the bugfix by disallowing undefined there.

from es5-shim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.