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

Event assignment doesn't work in templates #130

Closed
MotorHeat opened this issue Aug 31, 2020 · 1 comment
Closed

Event assignment doesn't work in templates #130

MotorHeat opened this issue Aug 31, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@MotorHeat
Copy link

MotorHeat commented Aug 31, 2020

Very good and nice library :)
I find a small bug. Check the below code.
Expected: when user press button alert should appear
Actual: nothing happens

import { observable, h } from "sinuous";
import { template, t, o } from 'sinuous/template';

const ButtonTemplate = template( () => h('div', 
      h('button', {onclick: o('buttonClick')}, 'Click me')
    )
);

let buttonClick = observable(() => { 
  alert('first click');
  buttonClick( () => alert('another handler!'));
})

let app = ButtonTemplate({ buttonClick: buttonClick })
document.body.append( app );

Same behavior with t instead o

This happens because api.property does't call event handler and relevant action is not recorded in template.js

I am not sure how to fix this to support observables

@MotorHeat MotorHeat changed the title Event assignment doesn't work in templates Event assignment doesn't work in templates [bug] Aug 31, 2020
@MotorHeat MotorHeat changed the title Event assignment doesn't work in templates [bug] Event assignment doesn't work in templates Aug 31, 2020
@luwes luwes added the bug Something isn't working label Sep 2, 2020
@luwes luwes closed this as completed in bb85b70 Sep 3, 2020
@luwes
Copy link
Owner

luwes commented Sep 3, 2020

Thanks for the bug report, this is fixed in 0.27.8 🎉
https://codesandbox.io/s/hungry-cloud-3wuc0?file=/src/index.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants