Skip to content

Commit

Permalink
removed faulty logic
Browse files Browse the repository at this point in the history
  • Loading branch information
13770129 committed Oct 23, 2024
1 parent 62af6bb commit 953c42d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/sonnet-core/src/core/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ interface Component<T> {
script?: () => void;
}

const EMPTY_HEAD = 'head(){return""}'
const EMPTY_SCRIPT = 'script(){}'
const EMPTY_HEAD = 'head(){return""}';
const EMPTY_SCRIPT = 'script(){}';

export function $component<T>(component: Component<T>) {
return (args?: T) => {
const instance = new component(args);
if (isBrowser()) {
// head tags
if (component.head?.toString() !== EMPTY_HEAD) {
if (component.head && component.head.toString() !== EMPTY_HEAD) {
event.once<SonnetHead>('head', component.head as () => SonnetHead);
}
if (instance.head?.toString() !== EMPTY_HEAD) {
if (instance.head && instance.head.toString() !== EMPTY_HEAD) {
event.on<SonnetHead>('head', instance.head.bind(instance));
}
// scripts
if (component.script?.toString() !== EMPTY_SCRIPT) {
if (component.script && component.script.toString() !== EMPTY_SCRIPT) {
event.once('script', component.script);
}
if (instance.script?.toString() !== EMPTY_SCRIPT) {
if (instance.script && instance.script.toString() !== EMPTY_SCRIPT) {
event.on('script', instance.script.bind(instance));
}
}
Expand Down

0 comments on commit 953c42d

Please sign in to comment.