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

Commit

Permalink
refactor: hoist refs directive as string
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Apr 16, 2021
1 parent 13bfe9a commit d1d4147
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ export const createASTNode = (el: HTMLElement, state: State): ASTNode | undefine

/* istanbul ignore next */
export const collectRefs = (): Refs => {
const refElements = document.querySelectorAll(`[${DIRECTIVE_PREFIX}ref]`);
const refDirective = `${DIRECTIVE_PREFIX}ref`;
const refElements = document.querySelectorAll(`[${refDirective}]`);
const refs = {};
refElements.forEach((refElement) => {
const name = refElement.getAttribute(`${DIRECTIVE_PREFIX}ref`);
const name = refElement.getAttribute(refDirective);
if (name) refs[name] = refElement;
});
return refs;
Expand Down

0 comments on commit d1d4147

Please # to comment.