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

IE8 Date is not mapped #8

Closed
lagoasoft-lucasschmidt opened this issue Aug 27, 2015 · 3 comments
Closed

IE8 Date is not mapped #8

lagoasoft-lucasschmidt opened this issue Aug 27, 2015 · 3 comments

Comments

@lagoasoft-lucasschmidt
Copy link

Hey guys, I noticed some issues in a few applications of mine, when users were using IE-8.

If I try to do a ko.mapping.toJS of an object that contains an observable property of a date, it would result in a {} empty object.

Fiddle: https://jsfiddle.net/gqsekzvp/3/

You cant actually run a fiddle on IE-8, I had to paste that in my own application. I will try to find out the issue, but if you guys have any idea, let me know.

I tried with Steves version as well, so this is possibly an old bug.

@lagoasoft-lucasschmidt
Copy link
Author

Well, I found out that the issue was that the code was failing here

    exports.getType = function(x) {
        if ((x) && (typeof (x) === "object")) {
            if (x.constructor === Date) return "date";
            if (x.constructor === Array) return "array";
        }
        return typeof x;
    };

due to the fact that we were using ES5-Shim, and somehow it was failing that code. I will have to audit here.

@crissdev
Copy link
Owner

@lucastschmidt Thanks for all the info. I tried your example in IE8 (emulated) and didn't encounter any issues. The following gist was used to test your example in an IE 11 instance emulating IE 8.

https://gist.github.com/crissdev/b5bcd8b5442f5690a130

@lagoasoft-lucasschmidt
Copy link
Author

@crissdev , yep, as I said the issue was in the project.

We use moment.js, es5-shim. Moment was being included before es5-shim, and for some reason, when moment executed the toDate() method, it was using a different prototype of Date.

moment (default Date) > es5-shim (replaces Date) > ko mapping (checks with new Date)

I dont know technically why it happened, I would guess only if moment had an old reference to the old Date prototype, otherwise, if moment was fetching the Date prototype dynamically, it would have worked I guess.

Either way, thanks. ES5-Shim should be before everything, so I fixed that.

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