CoffeeScriptRedux icon indicating copy to clipboard operation
CoffeeScriptRedux copied to clipboard

Object error

Open pYr0x opened this issue 11 years ago • 6 comments

i wrote a smal test with the CanJS framework.

$ ->
  can.Control.extend "sp.plugin.myPlugin",
    pluginName : 'myPlugin',
    defaults:
      myText: 'foo'
  ,
    init: (el) ->
      alert @options.myText

  $('body').myPlugin()

on coffee-script 1.7.0 the output is what i expected.

$(function() {
  can.Control.extend("sp.plugin.myPlugin", {
    pluginName: 'myPlugin',
    defaults: {
      myText: 'foo'
    }
  }, {
    init: function(el) {
      return alert(this.options.myText);
    }
  });
  return $('body').myPlugin();
});

on redux i get an error

Syntax error on line 6, column 2: unexpected ',' (\u002C)
3 : pluginName : 'myPlugin',
4 : defaults:
5 : myText: 'foo'
6 : ,
^ :~~^
7 : init: (el) ->
8 : alert @options.myText
9 : 

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

pYr0x avatar Jan 28 '14 22:01 pYr0x

See https://github.com/michaelficarra/CoffeeScriptRedux/wiki/Intentional-Deviations-From-jashkenas-coffee-script

vendethiel avatar Jan 28 '14 22:01 vendethiel

i looked at it before and didnt find an answer

pYr0x avatar Jan 28 '14 22:01 pYr0x

The dedented comma style that is typically discouraged is not yet supported. See related issue #232. Also, it's interesting that the leading whitespace in the error message seems to have disappeared.

michaelficarra avatar Jan 28 '14 22:01 michaelficarra

ok.. but is there a workaround?

pYr0x avatar Jan 28 '14 22:01 pYr0x

Just add the brackets

vendethiel avatar Jan 28 '14 22:01 vendethiel

I would give the object a name.

michaelficarra avatar Jan 28 '14 22:01 michaelficarra