Skip to content

Commit

Permalink
actually let's do this instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Jan 15, 2025
1 parent 1664fd8 commit 6402161
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { effect } from '../../reactivity/effects.js';
*/
export function attach(node, get_fn) {
effect(() => {
return (get_fn())?.(node);
const fn = get_fn();

// we use `&&` rather than `?.` so that things like
// `{@attach DEV && something_dev_only()}` work
return fn && fn(node);
});
}

0 comments on commit 6402161

Please sign in to comment.