vaderjs 1.3.3-alpha-15 → 1.3.3-alpha-16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/vader.js +12 -8
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "vaderjs",
3
3
  "description": "A Reactive library aimed to helping you build reactive applications inspired by react.js",
4
4
  "module": "vader.js",
5
- "version": "1.3.3-alpha-15",
5
+ "version": "1.3.3-alpha-16",
6
6
  "bin": {
7
7
  "vader": "./vader.js"
8
8
  },
package/vader.js CHANGED
@@ -25,17 +25,18 @@ function Compiler(func) {
25
25
  let savedfuncnames = [];
26
26
  let functions = string
27
27
  .match(
28
- /(?:const|let)\s*([a-zA-Z0-9_-]+)\s*=\s*function\s*\(([^)]*)\)|function\s*([a-zA-Z0-9_-]+)\s*\(([^)]*)\)/gs
28
+ /(?:const|let|var)?\s*([a-zA-Z0-9_-]+)\s*(?:=|function)\s*\(([^)]*)\)|function\s*([a-zA-Z0-9_-]+)\s*\(([^)]*)\)|(?:const|let|var)?\s*([a-zA-Z0-9_-]+)\s*=\s*\(([^)]*)\)/gs
29
29
  )
30
30
  ?.map((match) => match.trim());
31
31
 
32
+
32
33
  let functionNames = [];
33
34
 
34
35
  if (functions) {
35
36
  functions.forEach((func) => {
36
37
  if (
37
38
  !func.match(
38
- /(?:const|let)\s*([a-zA-Z0-9_-]+)\s*=\s*function\s*\(([^)]*)\)|function\s*([a-zA-Z0-9_-]+)\s*\(([^)]*)\)/gs
39
+ /(?:const|let|var)?\s*([a-zA-Z0-9_-]+)\s*(?:=|function)\s*\(([^)]*)\)|function\s*([a-zA-Z0-9_-]+)\s*\(([^)]*)\)|(?:const|let|var)?\s*([a-zA-Z0-9_-]+)\s*=\s*\(([^)]*)\)/gs
39
40
  )
40
41
  ) {
41
42
  return;
@@ -219,9 +220,9 @@ function Compiler(func) {
219
220
  otherdata["ref"] = ref;
220
221
 
221
222
  newvalue = newvalue.split('\n').map(line => line.trim() ? line.trim() + ';' : line).join('\n');
222
-
223
- let newatribute = `${attributeName}="\${this.bind(\`${newvalue}\` ${isJSXComponent ? "" : ","
224
- }${JSON.stringify(otherdata)} )}"`;
223
+ newvalue = newvalue.replaceAll('"', "'")
224
+ otherdata = JSON.stringify(otherdata).replaceAll('"', "'")
225
+ let newatribute = `${attributeName}="\${this.bind(\`${newvalue}\`${isJSXComponent ? "" : ","}${otherdata} )}"`;
225
226
 
226
227
 
227
228
  attribute[attributeName] = {
@@ -532,10 +533,13 @@ function Compiler(func) {
532
533
  });
533
534
 
534
535
 
535
- // turn props into object
536
- props = props.replace(/(\w+)=["']([^"']+)["']/g, '"$1": `$2`,');
536
+ // turn props into object
537
+ props = props.replaceAll('=', ':').replaceAll('/', '')
537
538
 
538
- props = props.replace("/", "");
539
+ // class="text-red-500" => class:"text-red-500", omit quotes if value is a variable
540
+ props = props.replaceAll(/([a-zA-Z0-9_-]+)\s*:\s*("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/gs, (match, p1, p2) => {
541
+ return match + ','
542
+ });
539
543
  let replace = "";
540
544
  replace = isChild
541
545
  ? `this.memoize(this.createComponent(${savedname.replaceAll('/', '')}, {${props}}, [${myChildrens.length > 0 ? myChildrens.join(",") : ""