@cilix/lightjs 0.0.11 → 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.
Files changed (2) hide show
  1. package/core.js +29 -12
  2. package/package.json +1 -1
package/core.js CHANGED
@@ -993,12 +993,33 @@ module.exports = (config, fs, path) => {
993
993
  };
994
994
  }
995
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
+
996
1001
  function parse_attributes() {
997
1002
  let attr = {};
998
1003
  let events = [];
999
1004
  while (true) {
1000
1005
  let key = tok.data;
1001
- if (accept("ident") || accept("as")) {
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")) {
1002
1023
  // allow ':' in attribute names
1003
1024
  while (accept(':')) {
1004
1025
  if (key === 'bind') {
@@ -1020,16 +1041,6 @@ module.exports = (config, fs, path) => {
1020
1041
  } else {
1021
1042
  attr[key] = { type: "bool", data: true };
1022
1043
  }
1023
- } else if (accept("on")) {
1024
- includeRuntime = true;
1025
- expect(":");
1026
- let handler;
1027
- let evt = tok.data;
1028
- expect("ident");
1029
- expect("=");
1030
- handler = parse_strict_string();
1031
- let nosync = accept('nosync');
1032
- events.push({ type: evt, handler: handler, sync: !nosync });
1033
1044
  } else {
1034
1045
  break;
1035
1046
  }
@@ -1296,7 +1307,13 @@ module.exports = (config, fs, path) => {
1296
1307
  next();
1297
1308
  let dst = { data: tok.data, pos: tok.pos, file: tok.file };
1298
1309
  expect('ident');
1299
- accept("=");
1310
+ if (!accept("=") && !accept(':')) {
1311
+ throw_error({
1312
+ msg: 'expected assignment',
1313
+ pos: tok.pos,
1314
+ file: tok.file
1315
+ });
1316
+ }
1300
1317
  let val = parse_rhs();
1301
1318
  ast_node('set', {
1302
1319
  global,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cilix/lightjs",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "A new kind of JavaScript framework",
5
5
  "main": "index.js",
6
6
  "scripts": {