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 #121 from aidenybai/revert-120-staging
Browse files Browse the repository at this point in the history
Revert "Staging"
  • Loading branch information
aidenybai authored Apr 15, 2021
2 parents 4f4dda6 + 1731624 commit 6777942
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 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 newState = { ...this.state, $render: this.render.bind(this) };
const $render = (deps: string[] = Object.keys(this.state)) => this.render(deps);

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

this.render();

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

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

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

0 comments on commit 6777942

Please # to comment.