Skip to content

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

Closed
@liammclennan

Description

@liammclennan

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

Activity

ben-x9

ben-x9 commented on May 10, 2010

@ben-x9

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

jashkenas commented on May 15, 2010

@jashkenas
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

d2kagw commented on Jun 28, 2010

@d2kagw

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

jashkenas commented on Jun 28, 2010

@jashkenas
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

satyr commented on Sep 7, 2010

@satyr
Collaborator

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

devinrhode2 commented on Dec 19, 2012

@devinrhode2

@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

toomim commented on Jun 26, 2015

@toomim

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jashkenas@d2kagw@satyr@toomim@liammclennan

        Issue actions

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