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

Commit ca9f87f

Browse files
fix(component-parser.js): fix scopedSelector being redefined on delayed callbacks like setTimeout (#44)
* fix(component-parser.js): parse scopedSelector to document.querySelector on build * bump to 0.4.2
1 parent 9a820d6 commit ca9f87f

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,5 @@ out.html
105105
.tern-port
106106

107107
# playground of vm module
108-
vm.playground.js
108+
playground.js
109109
srcold/

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ examples/
55
.eslintignore
66
.prettierrc
77
.prettierignore
8-
vm.playground.js
8+
playground.js
99
.vscode/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "abell-renderer",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "JavaScript based Template Engine. Compiles .abell files to .html",
55
"main": "src/index.js",
66
"bin": {

src/parsers/component-parser.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ function parseComponent(
172172
} else if (!isCss && contentMatch[2].includes('scopedSelector')) {
173173
// if it is javascript then scope it by injecting scopedSelector functions
174174
// prettier-ignore
175-
content =
176-
`scopedSelector = (queryString) => document.querySelector(queryString + '[data-abell-${componentHash}]');` + // eslint-disable-line max-len
177-
`scopedSelectorAll = (queryString) => document.querySelectorAll(queryString + '[data-abell-${componentHash}]');` // eslint-disable-line max-len
178-
+ contentMatch[2];
175+
content = contentMatch[2].replace(
176+
/scoped(Selector|SelectorAll)\((['"`].*?["'`])\)/g,
177+
`document.query$1($2 + "[data-abell-${componentHash}]")`
178+
);
179179
} else {
180180
content = contentMatch[2];
181181
}

0 commit comments

Comments
 (0)