riot/compiler

Riot compiler behavior on compiling method

Closed this issue · 2 comments

  1. Describe your issue:
    When I place { opening bracket of method on new line in <script> tag, Riot compiler don't build my method correctly.

  2. Can you reproduce the issue?

<my-tag>
  <h1>{ message }</h1>
  <button onclick={ handleClick }>Button 1</button>
  <button onclick={ handleClickBad }>Button 2</button>

  <script>
    this.message = 'hello there'
    
    handleClick(e) {
      this.message = 'Click';
    }
    
    handleClickBad(e)
    {
      this.message = 'Click bad';
    }
    
  </script>
</my-tag>

becomes this

riot.tag('my-tag', '<h1>{ message }</h1><button onclick={ handleClick }>Button 1</button><button onclick={ handleClickBad }>Button 2</button>', function(opts){
  this.message = 'hello there'
    
    this.handleClick = function(e) {
      this.message = 'Click';
    }.bind(this);
    
    handleClickBad(e)
    {
      this.message = 'Click bad';
    }
}));
  1. On which browser/OS does the issue appear?
    Ubuntu 16.04

  2. Which version of Riot does it affect?
    Riot 2.6.7 compiled with grunt-riot

  3. How would you tag this issue?

  • Question
  • Bug
  • Discussion
  • Feature request
  • Tip
  • Enhancement
  • Performance

Moved from riot/riot/issues/2065

This is not a riot-compiler issue https://runkit.com/gianlucaguarini/riot-compiler-rendering-test
gruint-riot uses an old riot release I recommend to open the issue directly on grunt-riot or just to use the official riot compiler/cli

Thanks for response