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

Commit

Permalink
fix(component-parser.js): fix scopedSelector being redefined on delay…
Browse files Browse the repository at this point in the history
…ed callbacks like setTimeout (#44)

* fix(component-parser.js): parse scopedSelector to document.querySelector on build

* bump to 0.4.2
  • Loading branch information
saurabhdaware authored Mar 14, 2021
1 parent 9a820d6 commit ca9f87f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ out.html
.tern-port

# playground of vm module
vm.playground.js
playground.js
srcold/
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ examples/
.eslintignore
.prettierrc
.prettierignore
vm.playground.js
playground.js
.vscode/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "abell-renderer",
"version": "0.4.1",
"version": "0.4.2",
"description": "JavaScript based Template Engine. Compiles .abell files to .html",
"main": "src/index.js",
"bin": {
Expand Down
8 changes: 4 additions & 4 deletions src/parsers/component-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ function parseComponent(
} else if (!isCss && contentMatch[2].includes('scopedSelector')) {
// if it is javascript then scope it by injecting scopedSelector functions
// prettier-ignore
content =
`scopedSelector = (queryString) => document.querySelector(queryString + '[data-abell-${componentHash}]');` + // eslint-disable-line max-len
`scopedSelectorAll = (queryString) => document.querySelectorAll(queryString + '[data-abell-${componentHash}]');` // eslint-disable-line max-len
+ contentMatch[2];
content = contentMatch[2].replace(
/scoped(Selector|SelectorAll)\((['"`].*?["'`])\)/g,
`document.query$1($2 + "[data-abell-${componentHash}]")`
);
} else {
content = contentMatch[2];
}
Expand Down

0 comments on commit ca9f87f

Please sign in to comment.