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

script/coffeescript tags don't work in IE 8 #366

Closed
liammclennan opened this issue May 9, 2010 · 7 comments
Closed

script/coffeescript tags don't work in IE 8 #366

liammclennan opened this issue May 9, 2010 · 7 comments

Comments

@liammclennan
Copy link

I get an error immediately when I go to http://jashkenas.github.com/coffee-script/ in Internet Explorer 8.

The text of the error is:

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E)
Timestamp: Sun, 9 May 2010 06:29:18 UTC

Message: 'prototype' is null or not an object
Line: 1
Char: 251857
Code: 0
URI: http://jashkenas.github.com/coffee-script/extras/coffee-script.js

@ben-x9
Copy link

ben-x9 commented May 10, 2010

I just ran into this issue myself running the script locally.

I attempted to rollback to 0.5.6 just in case this bug was something recently introduced, but got a different error:

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; FDM; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Timestamp: Mon, 10 May 2010 13:48:20 UTC

Message: 'undefined' is null or not an object
Line: 1
Char: 21693
Code: 0
URI: lib/coffee-script-0.5.6.js

@jashkenas
Copy link
Owner

Sorry about the IE broken-ness. extras/coffee-script.js is now fixed on master, and should work live on the Internet Explorer of your choosing.

The two issues which had to be solved were these:

  • We needed a custom implementation of Array#indexOf, naturally. I added one to Helpers.
  • IE is buggy with respect to named function expressions and lexical scope. A named function defined within an inner function will effectively prevent the variable from being passed out to the outer function, where the variable was declared. This is enough of a showstopper to force us to remove named functions from CoffeeScript altogether, unfortunately. It's only a two-line change, but they were great for debugging, so it's sad to see them go.

Closing the ticket.

@d2kagw
Copy link

d2kagw commented Jun 28, 2010

That's a massive shame.
I was using the named functions when looping through classes to detect the type of the class.
For example:
class Person
getName: ->
@name

class Neo extends Person
  name: "Neo

n: new Neo()
console.warn n.constructor.name

Would have output "Neo", but now it's just "" (empty string).
Any ideas of other ways of getting the class name?

@jashkenas
Copy link
Owner

The function isn't named anymore (because of the IE bug), so no -- there isn't a way to get its name, apart from tagging it manually with a property. A real shame, I completely agree.

@satyr
Copy link
Collaborator

satyr commented Sep 7, 2010

Why not keep them named, but with some prefix and/or suffix to avoid name collisions. e.g.:
fn = ->
into
var fn;
fn = function __fn() {}

@devinrhode2
Copy link

@jashkenas are there ANY scenarios where we can put in function names? I've been working on TraceKit.js and was oblivious to this IE error, me and @occ will probably re-write TraceKit in coffeescript.

@satyr mentioned giving them a prefix, which is way better for a stack trace than a helpless (anonymous function)

We could even add a few random numbers to the end of the function name, a very simple and easy to implement solution, that would also be very robust. Soon thereafter, we could focus on prefixing by the class name and more deterministic identifiers.

I could totally work on this, very carefully of course.

@toomim
Copy link

toomim commented Jun 26, 2015

This feature indeed is useful for debugging. What about enabling it as an option that people can enable in development, when testing on chrome/firefox/safari? They could then disable it in production.

I'd also be able to use this option for most of my coffeescript projects because they compile in the browser. So I can detect at run-time if the browser is not IE, and if so, enable the anonymous named functions.

This issue was closed.
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

7 participants