From 9a093c49c6a76cba61c5e22e15e9629a7a657007 Mon Sep 17 00:00:00 2001 From: Alex Kanunnikov Date: Wed, 31 Jan 2024 22:25:37 +0300 Subject: [PATCH] + --- src/utils/dom.ts | 47 +++++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/utils/dom.ts b/src/utils/dom.ts index 54280d68..3903b3ba 100644 --- a/src/utils/dom.ts +++ b/src/utils/dom.ts @@ -1114,46 +1114,42 @@ export const $_maybeModifier = ( modifier: any, element: HTMLElement, props: any[], - hashArgs: () => Record, + hashArgs, ) => { if ('emberModifier' in modifier) { const instance = new modifier(); instance.modify = instance.modify.bind(instance); const destructors: Destructors = []; + console.log('running class-based modifier'); + requestAnimationFrame(() => { + const f = formula(() => { + instance.modify(element, props, hashArgs); + }, 'class-based modifier'); + destructors.push( + opcodeFor(f, () => { + console.log('opcode executed for modifier'); + }), + ); + }); return () => { - console.log('running class-based modifier'); - requestAnimationFrame(() => { - const f = formula(() => { - instance.modify(element, props, hashArgs()); - }, 'class-based modifier'); - destructors.push( - opcodeFor(f, () => { - console.log('opcode executed for modifier'); - }), - ); - }); - return () => { - destructors.forEach((fn) => fn()); - console.log('destroing class-based modifier'); - if ('willDestroy' in instance) { - instance.willDestroy(); - } - runDestructors(instance); - }; + destructors.forEach((fn) => fn()); + console.log('destroing class-based modifier'); + if ('willDestroy' in instance) { + instance.willDestroy(); + } + runDestructors(instance); }; } else { // console.log(modifier); if (EmberFunctionalModifiers.has(modifier)) { - return (element: HTMLElement) => { - console.log('ember-functional-modifier', props, hashArgs()); - const args = hashArgs(); + console.log('ember-functional-modifier', props, hashArgs); + const args = hashArgs; const newArgs = {}; Object.keys(args).forEach((key) => { Object.defineProperty(newArgs, key, { enumerable: true, get() { if (typeof args[key] === 'function') { - // @ts-expect-error function signature return args[key](); } else { return args[key]; @@ -1162,9 +1158,8 @@ export const $_maybeModifier = ( }); }); return modifier(element, props, newArgs); - }; } - return modifier; + return modifier(element, ...props); } }; export const $_helper = (helper: any) => {