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

In IE8 'T' format in new Date results in Error when including es5-shim instead of Default Browser Behaviour of NAN #303

Closed
smoothlikejazz opened this issue May 19, 2015 · 4 comments
Assignees

Comments

@smoothlikejazz
Copy link

Issue
In IE8 using the Date instance and executing a new date including the 'T' format results in an error outlined below when including the es5-shim.

* Sample*

<script src="es5-shim.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
        console.log(new Date("2015-05-18T21:55:18Z"));
</script>

Results in Error
Object doesn't support this property or method es5-shim.js, line 926 character 21

Default Behaviour without Shim
Running the same sample above without the shim, IE8 will return NAN.

Context
In our current application we are handling NAN, the problem is that some third-party libraries are using new Date() and the error is occurring within the external library when including the es5-shim. So we isolated the issue in IE8 to be that of the new Date with 'T' format.

Conclusion
Were not sure why when including the es5-shim this fatal error is happening for IE8. but would like to request a patch or fix.

@ljharb
Copy link
Member

ljharb commented May 19, 2015

Thanks, I definitely see this error. I'll see if I can investigate - I'm not sure what version of the es5-shim you're running - can you provide an example of what line 926 looks like, so I can map it to my version?

@smoothlikejazz
Copy link
Author

Hey sure no problem, thanks for looking into, here is the snippet from my checked out version.

           var DateShim = function Date(Y, M, D, h, m, s, ms) {
                var length = arguments.length;
                if (this instanceof NativeDate) {
                    var date = length === 1 && String(Y) === Y ? // isString(Y) // --> Line 926
                        // We explicitly pass it through parse:
                        new NativeDate(Date.parse(Y)) :
                        // We have to manually make calls depending on argument
                        // length here
                        length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
                            length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
                                length >= 5 ? new NativeDate(Y, M, D, h, m) :
                                    length >= 4 ? new NativeDate(Y, M, D, h) :
                                        length >= 3 ? new NativeDate(Y, M, D) :
                                            length >= 2 ? new NativeDate(Y, M) :
                                                length >= 1 ? new NativeDate(Y) :
                                                    new NativeDate();
                    // Prevent mixups with unfixed Date object
                    defineProperties(date, { constructor: Date }, true);
                    return date;
                }
                return NativeDate.apply(this, arguments);
            };

@ljharb
Copy link
Member

ljharb commented May 19, 2015

And which of those lines is 926? I think we're off by 1-2 :-)

@smoothlikejazz
Copy link
Author

For me it falls on this.

926: var date = length === 1 && String(Y) === Y ? // isString(Y)

screen shot 2015-05-18 at 10 27 02 pm

@ljharb ljharb self-assigned this May 21, 2015
@ljharb ljharb closed this as completed in 9fb2120 May 21, 2015
ljharb added a commit to paulmillr/es6-shim that referenced this issue Oct 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants