@cilix/lightjs 0.0.10 → 0.0.12
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.
- package/core.js +34 -18
- package/package.json +1 -1
package/core.js
CHANGED
|
@@ -771,7 +771,7 @@ module.exports = (config, fs, path) => {
|
|
|
771
771
|
return acc;
|
|
772
772
|
}
|
|
773
773
|
|
|
774
|
-
function parse_atom () {
|
|
774
|
+
function parse_atom (noacc) {
|
|
775
775
|
let unop = tok.data;
|
|
776
776
|
let expr = { pos: tok.pos, file: tok.file };
|
|
777
777
|
if (accept('!') || accept('-')) {
|
|
@@ -814,6 +814,9 @@ module.exports = (config, fs, path) => {
|
|
|
814
814
|
} else {
|
|
815
815
|
unexpected();
|
|
816
816
|
}
|
|
817
|
+
if (noacc) {
|
|
818
|
+
return expr;
|
|
819
|
+
}
|
|
817
820
|
let acc = parse_acc();
|
|
818
821
|
if (acc) {
|
|
819
822
|
acc.unshift(expr);
|
|
@@ -990,12 +993,33 @@ module.exports = (config, fs, path) => {
|
|
|
990
993
|
};
|
|
991
994
|
}
|
|
992
995
|
|
|
996
|
+
function isEventHandler(ident) {
|
|
997
|
+
const c = ident[2];
|
|
998
|
+
return ident.indexOf('on') === 0 && c.length === 1 && c === c.toUpperCase() && c !== c.toLowerCase();
|
|
999
|
+
}
|
|
1000
|
+
|
|
993
1001
|
function parse_attributes() {
|
|
994
1002
|
let attr = {};
|
|
995
1003
|
let events = [];
|
|
996
1004
|
while (true) {
|
|
997
1005
|
let key = tok.data;
|
|
998
|
-
if (
|
|
1006
|
+
if (peek("on") || (peek('ident') && isEventHandler(tok.data))) {
|
|
1007
|
+
includeRuntime = true;
|
|
1008
|
+
let handler;
|
|
1009
|
+
let evt;
|
|
1010
|
+
if (accept('on')) {
|
|
1011
|
+
console.log('YEAHHHHH')
|
|
1012
|
+
expect(":");
|
|
1013
|
+
evt = tok.data;
|
|
1014
|
+
} else {
|
|
1015
|
+
evt = tok.data.replace('on', '').toLowerCase();
|
|
1016
|
+
}
|
|
1017
|
+
expect("ident");
|
|
1018
|
+
expect("=");
|
|
1019
|
+
handler = parse_strict_string();
|
|
1020
|
+
let nosync = accept('nosync');
|
|
1021
|
+
events.push({ type: evt, handler: handler, sync: !nosync });
|
|
1022
|
+
} else if (accept("ident") || accept("as")) {
|
|
999
1023
|
// allow ':' in attribute names
|
|
1000
1024
|
while (accept(':')) {
|
|
1001
1025
|
if (key === 'bind') {
|
|
@@ -1012,25 +1036,11 @@ module.exports = (config, fs, path) => {
|
|
|
1012
1036
|
} else if (peek("string")) {
|
|
1013
1037
|
attr[key] = parse_string();
|
|
1014
1038
|
} else {
|
|
1015
|
-
|
|
1016
|
-
msg: "unexpected " + tok.type,
|
|
1017
|
-
pos: tok.pos,
|
|
1018
|
-
file: tok.file
|
|
1019
|
-
});
|
|
1039
|
+
attr[key] = parse_atom(true);
|
|
1020
1040
|
}
|
|
1021
1041
|
} else {
|
|
1022
1042
|
attr[key] = { type: "bool", data: true };
|
|
1023
1043
|
}
|
|
1024
|
-
} else if (accept("on")) {
|
|
1025
|
-
includeRuntime = true;
|
|
1026
|
-
expect(":");
|
|
1027
|
-
let handler;
|
|
1028
|
-
let evt = tok.data;
|
|
1029
|
-
expect("ident");
|
|
1030
|
-
expect("=");
|
|
1031
|
-
handler = parse_strict_string();
|
|
1032
|
-
let nosync = accept('nosync');
|
|
1033
|
-
events.push({ type: evt, handler: handler, sync: !nosync });
|
|
1034
1044
|
} else {
|
|
1035
1045
|
break;
|
|
1036
1046
|
}
|
|
@@ -1297,7 +1307,13 @@ module.exports = (config, fs, path) => {
|
|
|
1297
1307
|
next();
|
|
1298
1308
|
let dst = { data: tok.data, pos: tok.pos, file: tok.file };
|
|
1299
1309
|
expect('ident');
|
|
1300
|
-
accept("=")
|
|
1310
|
+
if (!accept("=") && !accept(':')) {
|
|
1311
|
+
throw_error({
|
|
1312
|
+
msg: 'expected assignment',
|
|
1313
|
+
pos: tok.pos,
|
|
1314
|
+
file: tok.file
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1301
1317
|
let val = parse_rhs();
|
|
1302
1318
|
ast_node('set', {
|
|
1303
1319
|
global,
|