diff --git a/src/index.js b/src/index.js index ab05adb1..6fdc2d69 100644 --- a/src/index.js +++ b/src/index.js @@ -182,6 +182,7 @@ export class Tonic extends window.HTMLElement { } case '[object Object]': case '[object Function]': + case '[object AsyncFunction]': case '[object Set]': case '[object Map]': case '[object WeakMap]': return this._prop(o) diff --git a/test/index.js b/test/index.js index a3c48064..81233876 100644 --- a/test/index.js +++ b/test/index.js @@ -12,6 +12,45 @@ test('sanity', async t => { t.ok(parseInt(parts[0]) >= 10) }) +test('pass an async function as an event handler', t => { + t.plan(1) + + class TheApp extends Tonic { + async clicker (msg) { + t.equal(msg, 'hello', 'should get the event') + } + + render () { + return this.html`
+ +
` + } + } + + class FnExample extends Tonic { + click (ev) { + ev.preventDefault() + this.props.onbtnclick('hello') + } + + render () { + return this.html`
+ example + +
` + } + } + + document.body.innerHTML = ` + + ` + + Tonic.add(FnExample) + Tonic.add(TheApp) + + document.getElementById('btn').click() +}) + test('get kebab case from camel case', t => { const kebab = Tonic.getTagName('MyExample') t.equal(typeof kebab, 'string', 'should return a string')