diff --git a/index.mjs b/index.mjs index 44031c35c8..55f227749e 100644 --- a/index.mjs +++ b/index.mjs @@ -3,5 +3,6 @@ export { onDestroy, beforeUpdate, afterUpdate, + add_render_callback as afterFlush, createEventDispatcher } from './internal'; diff --git a/test/runtime/samples/lifecycle-after-flush/_config.js b/test/runtime/samples/lifecycle-after-flush/_config.js new file mode 100644 index 0000000000..222dd26286 --- /dev/null +++ b/test/runtime/samples/lifecycle-after-flush/_config.js @@ -0,0 +1,20 @@ +export default { + async test({ assert, component, target, window }) { + const button = target.querySelector('button'); + const click = new window.MouseEvent('click'); + + await button.dispatchEvent(click); + assert.deepEqual(component.snapshots, [ + 'before 0', + 'after 1' + ]); + + await button.dispatchEvent(click); + assert.deepEqual(component.snapshots, [ + 'before 0', + 'after 1', + 'before 1', + 'after 2' + ]); + } +}; diff --git a/test/runtime/samples/lifecycle-after-flush/main.html b/test/runtime/samples/lifecycle-after-flush/main.html new file mode 100644 index 0000000000..0e6b76d0f3 --- /dev/null +++ b/test/runtime/samples/lifecycle-after-flush/main.html @@ -0,0 +1,19 @@ + + + \ No newline at end of file