Skip to content

Commit

Permalink
+
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeart committed Jan 31, 2024
1 parent a2f41a6 commit 9a093c4
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1114,46 +1114,42 @@ export const $_maybeModifier = (
modifier: any,
element: HTMLElement,
props: any[],
hashArgs: () => Record<string, unknown>,
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];
Expand All @@ -1162,9 +1158,8 @@ export const $_maybeModifier = (
});
});
return modifier(element, props, newArgs);
};
}
return modifier;
return modifier(element, ...props);
}
};
export const $_helper = (helper: any) => {
Expand Down

0 comments on commit 9a093c4

Please sign in to comment.