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

Fix missing methods/globals in IE7, IE8 environments #2259

Closed
wants to merge 1 commit into from

Conversation

ndhoule
Copy link
Contributor

@ndhoule ndhoule commented May 16, 2016

This patch fixes two incompatibilities in pre-ES5 environments:

  • Missing JSON global (IE7)
  • Missing Date#toISOString method (IE7, IE8)

@ndhoule
Copy link
Contributor Author

ndhoule commented May 16, 2016

CI failure seems unrelated to PR, anyone care to re-run it?

@ScottFreeCode
Copy link
Contributor

Actually, the failure might be due to the PR; Node 0.8, and only Node 0.8, is complaining about the added "@segment/to-iso-string" dependency, reacting as though you'd specified a dependency named just "segment". It's hard to find documentation that far back to confirm it, but I'd hypothesize that scoped dependencies weren't supported in the version of NPM that comes with Node 0.8...

@ndhoule
Copy link
Contributor Author

ndhoule commented May 16, 2016

Huh—I would think that this script would update npm before installing deps. That was the intention behind adding it, anyway.

Not really sure why we try to install non-devDeps using the version of npm bundled with node 0.8; updating npm on that platform should be a non-issue. At least that's what we decided back when we Browserified (ref). @dasilvacontin probably has an opinion here.

Also happy to swap the dep out with a non-namespaced one if someone can suggest one. I wasn't able to find any other toISOString modules that weren't buggy/incomplete (though I didn't search too hard as I already knew this one existed)

@ScottFreeCode
Copy link
Contributor

It looks like #2236 was deliberately designed to check this.

For what it's worth, recently I've seen this discussion about supporting 0.8 out of the box:
#2200 (comment)
#2121 (comment)

@dasilvacontin
Copy link
Contributor

dasilvacontin commented May 17, 2016

Huh—I would think that this script would update npm before installing deps. That was the intention behind adding it, anyway.

Not really sure why we try to install non-devDeps using the version of npm bundled with node 0.8; updating npm on that platform should be a non-issue. At least that's what we decided back when we Browserified (ref). @dasilvacontin probably has an opinion here.

It looks like #2236 was deliberately designed to check this.

For what it's worth, recently I've seen this discussion about supporting 0.8 out of the box:
#2200 (comment)
#2121 (comment)

We are currently supporting it out of the box – not sure if there's really a reason why users can't upgrade npm, or if we do so out of convenience (/cc @boneskull). Still, to stop supporting node v0.8 out of the box would be a breaking change.

Also happy to swap the dep out with a non-namespaced one if someone can suggest one. I wasn't able to find any other toISOString modules that weren't buggy/incomplete (though I didn't search too hard as I already knew this one existed)

That would be ideal. We can switch to the one you proposed when we bump the major version.

Also, @boneskull, pretty sure these changes will be needed for the browser testing ticket. Otherwise you'll likely bump into the exception.

"commander": "2.3.0",
"debug": "2.2.0",
"diff": "1.4.0",
"escape-string-regexp": "1.0.2",
"glob": "3.2.11",
"growl": "1.9.2",
"jade": "0.26.3",
"json3": "^3.3.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Carret makes npm cry.

@dasilvacontin
Copy link
Contributor

Thanks for the PR, btw!

@ScottFreeCode
Copy link
Contributor

We ended up getting toISOString shimmed in #2231; @boneskull, do we want to look at IE7 support and see whether it would take anything more than falling back on a library like this for JSON in the event it's missing too?

@boneskull
Copy link
Contributor

Has Mocha ever supported IE7?

@boneskull
Copy link
Contributor

I'm going to rebase this and see what happens.

@boneskull
Copy link
Contributor

Oh, right, it's failing b/c of the caret. It looks like there was some implicit support for IE7 somewhere.

@boneskull
Copy link
Contributor

boneskull commented Jun 10, 2016

Rebased branch is here.
Build is here here.

@ScottFreeCode
Copy link
Contributor

Is it possible to test that we don't add JSON to the global namespace? The main reason for that being that we don't want people running tests of code that uses JSON and having those tests pass because of the shim/polyfill pulled in by Mocha when in fact their code will fail outside of testing due to lack of the shim/polyfill. (I just manually checked and it seems to be ok, but it'd be nice to confirm it never ends up otherwise, e.g. by future changes that need to use JSON in new places internally.)

I suppose the same thing could hypothetically go for other shims/polyfills too, although it seems like most of the others I've seen are just acting as function variables used instead of the native stuff and not standing in place of native global variables.

Also, if this does work, we should try adding IE7 to the Sauce tests. For that matter, maybe we should see if it will go back all the way to 5 or 6? (Heh heh, do those still exist? Weird fact: the compatibility mode setting in IE11's developer console has modes for 10, 9, 8, 7 and 5. That's right, 5, which nobody even talks about anymore, but not 6.)

@ScottFreeCode
Copy link
Contributor

One other question: Does "json3" just return the existing JSON global if it's available? If not, we may want to use var JSON = typeof JSON !== "undefined" ? JSON : require("json3"); instead of just var JSON = require("json3");

@dasilvacontin
Copy link
Contributor

@ScottFreeCode Apparently, it does: https://github.com/bestiejs/json3/blob/master/lib/json3.js#L43-L47

But it also checks if the native implementation is spec compliant and stuff.

@boneskull
Copy link
Contributor

boneskull commented Jun 11, 2016

I've rebased my branch onto master and added an IE7 test. Build Build Build

@boneskull
Copy link
Contributor

Alright, this is passing. I'm going to merge the branch. @ndhoule Thanks for getting this started!

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

Successfully merging this pull request may close these issues.

4 participants