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

.on('update') bug #338

Closed
e-jigsaw opened this issue Feb 10, 2015 · 9 comments
Closed

.on('update') bug #338

e-jigsaw opened this issue Feb 10, 2015 · 9 comments
Labels

Comments

@e-jigsaw
Copy link
Contributor

Sample code:

parent.tag:

<parent>
  <child1 data='{ data }'></child1>
  <child2 update='{ updateChild1 }'></child2>

  this.data = 'hoge'
  this.updateChild1 = function(event) {
    this.update({
      data: 'fuga'
    })
  }.bind(this)
</parent>

child1.tag:

<child1>
  <p>child 1</p>

  this.on('update', function(event){
    console.log(opts.data)
  })
</child1>

child2.tag:

<child2>
  <button onclick='{ onclick }'>test</button>
  this.onclick = function(event) {
    console.log('click')
    opts.update(event)
  }
</child2>

This code is show opts.data in child1 each click in child2 button.

in riot@2.0.7:

hoge
hoge
click
fuga

in riot@2.0.8:

hoge
hoge
click
hoge
click
fuga

.on('update') is delayed. Does this behavior would be a bug?

Thanks

@e-jigsaw
Copy link
Contributor Author

And each evaluate delayed too.

@tipiirai
Copy link
Contributor

Can you try what happens with the latest version (v2.0.10)? Thanks!

@e-jigsaw
Copy link
Contributor Author

@tipiirai latest version still happen

@e-jigsaw
Copy link
Contributor Author

I checked a code. But still I can not find where cased this behavior...

https://github.com/muut/riotjs/blob/master/lib/tmpl.js#L76

This line returns undefined when first delay in first call. Then

https://github.com/muut/riotjs/blob/master/lib/tag/each.js#L54-L55

tmpl returns undefined. And update finishes by L55.

fmm...

@tipiirai
Copy link
Contributor

The current version on dev branch prints

hoge
hoge
click
fuga

You can get it from dist/riot folder with make riot command

@tipiirai tipiirai added the fixed label Feb 21, 2015
@e-jigsaw
Copy link
Contributor Author

make fall...

✈ make riot
# check code style
# run the mocha tests


  Riotjs tests
    Compiler Cli
      ✓ strings
    Tmpl
      ✓ compiles specs (38ms)
      ✓ custom brackets
    Observable
      ✓ single listener
      ✓ multiple listeners with special chars
      ✓ one
      ✓ one & on
      ✓ Remove listeners
      ✓ Remove multiple listeners
      ✓ Removes duplicate callbacks on off for specific handler
      ✓ is able to trigger events inside a listener
      ✓ Multiple arguments
      ✓ Remove all listeners
      ✓ Remove specific listener
      ✓ should not throw internal error
      1) multi off
      ✓ remove handler while triggering
      does not call trigger infinitely
        ✓ 2 calls are enough to know the test failed
    route
      ✓ it detecs the hash params


  18 passing (69ms)
  1 failing

  1) Riotjs tests Observable multi off:
     Error: expected 2 to equal 0

@e-jigsaw
Copy link
Contributor Author

BTW dist/riot.js is worked! Awesome!!

@e-jigsaw
Copy link
Contributor Author

I am looking forward to the next release

@cfenzo
Copy link
Contributor

cfenzo commented Feb 23, 2015

Thanks for fixing this bug :) it had me tearing out some hairs for a while there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants