jashkenas / coffeescript

Unfancy JavaScript
https://coffeescript.org/
MIT License
16.51k stars 1.99k forks source link

"WHEN" keyword not parsed correctly when used as a key #2735

Closed omrsin closed 11 years ago

omrsin commented 11 years ago

Hello,

I'm using a flipbook js library called turn.js. This library uses certain keys when creating the flibooks. For example in normal js it would be like this:

$(flipbook).turn({
   width: 922,
   height: 600,
   autoCenter: true,
   pages: 12,
   when: {
       turning: function(event, page, view) {
       }
   }
});

If I use coffeescript it goes like this:

$(flipbook).turn
    width:922,
    height:600,
    autoCenter: true,
    pages: 12,
    when:
        turning: (event, page, view)  ->

But it ends up parsing like this:

$(flipbook).turn({
          width: 912,
          height: 650,
          elevation: 50,
          gradients: true,
          autoCenter: true
        }, {
          when: {
            turning: function(event, page, view) {
            }
         }
      }
 );

I'm guessing it is a problem with the WHEN keyword being recognized as a special word for the switch instruction.

Thanks

vendethiel commented 11 years ago

Looks like a specialcase of a specialcase. Maybe that's fixed by #2712

jashkenas commented 11 years ago

Looks like it's fixed on master for me. Should be fine in the next release.

omrsin commented 11 years ago

Thanks! I'll keep an eye on it also in the coffee-rails gem