Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #123 from owochlo/staging
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai authored Apr 15, 2021
2 parents 6777942 + c4054c0 commit 457d720
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export class Component {
typeof el === 'string'
? document.querySelector<HTMLElement>(el) || document.body
: (el as HTMLElement);
const $render = (deps: string[] = Object.keys(this.state)) => this.render(deps);
const newState = { ...this.state, $render: this.render.bind(this) };

this.ast = compile(rootEl, this.state);
this.directives = { ...this.directives, ...directives };
this.state = reactive({ ...this.state, $render }, this.render.bind(this), this.watchers);
this.state = reactive(newState, this.render.bind(this), this.watchers);

this.render();

Expand Down
3 changes: 1 addition & 2 deletions src/core/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ export const isListRenderScope = (el: HTMLElement): boolean => {
};

export const isUnderListRenderScope = (el: HTMLElement): boolean => {
if (!el.parentElement) return false;
return el.parentElement.hasAttribute(`${DIRECTIVE_PREFIX}for`);
return el.parentElement && el.parentElement.hasAttribute(`${DIRECTIVE_PREFIX}for`);
};

export const createASTNode = (el: HTMLElement, state: State): ASTNode | undefined => {
Expand Down

0 comments on commit 457d720

Please sign in to comment.