malinajs 0.6.51 → 0.6.54
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/compile.js +20 -23
- package/malina.js +21 -24
- package/package.json +1 -1
- package/runtime.js +3 -3
package/compile.js
CHANGED
|
@@ -19,7 +19,7 @@ function assert(x, info) {
|
|
|
19
19
|
|
|
20
20
|
function toCamelCase(name) {
|
|
21
21
|
assert(name[name.length - 1] !== '-', 'Wrong name');
|
|
22
|
-
return name.replace(/(\-\w)/g, function(part) {
|
|
22
|
+
return name.replace(/(?<!-)(\-\w)/g, function(part) {
|
|
23
23
|
return part[1].toUpperCase();
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -55,19 +55,10 @@ function detectExpressionType(name) {
|
|
|
55
55
|
let ast = acorn.parse(name, {allowReturnOutsideFunction: true});
|
|
56
56
|
|
|
57
57
|
function checkIdentificator(body) {
|
|
58
|
-
if(body.length != 1) return;
|
|
59
|
-
if(body[0].type != 'ExpressionStatement') return;
|
|
60
|
-
if(body[0].expression.type != 'Identifier') return;
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function checkMemberIdentificator(body) {
|
|
65
58
|
if(body.length != 1) return;
|
|
66
59
|
if(body[0].type != 'ExpressionStatement') return;
|
|
67
60
|
let obj = body[0].expression;
|
|
68
|
-
|
|
69
|
-
if(obj.property.type != 'Identifier') return;
|
|
70
|
-
return true;
|
|
61
|
+
return obj.type == 'Identifier' || obj.type == 'MemberExpression';
|
|
71
62
|
}
|
|
72
63
|
|
|
73
64
|
function checkFunction(body) {
|
|
@@ -79,7 +70,6 @@ function detectExpressionType(name) {
|
|
|
79
70
|
}
|
|
80
71
|
|
|
81
72
|
if(checkIdentificator(ast.body)) return 'identifier';
|
|
82
|
-
if(checkMemberIdentificator(ast.body)) return 'identifier';
|
|
83
73
|
if(checkFunction(ast.body)) return 'function';
|
|
84
74
|
|
|
85
75
|
return;
|
|
@@ -829,7 +819,8 @@ function parse() {
|
|
|
829
819
|
} else continue;
|
|
830
820
|
|
|
831
821
|
return {
|
|
832
|
-
value: source.substring(start + 1, index - 1)
|
|
822
|
+
value: source.substring(start + 1, index - 1),
|
|
823
|
+
raw: source.substring(start, index)
|
|
833
824
|
};
|
|
834
825
|
}
|
|
835
826
|
};
|
|
@@ -846,6 +837,16 @@ function parse() {
|
|
|
846
837
|
const go = (parent) => {
|
|
847
838
|
let textNode = null;
|
|
848
839
|
|
|
840
|
+
const addText = v => {
|
|
841
|
+
if(!textNode) {
|
|
842
|
+
textNode = {
|
|
843
|
+
type: 'text',
|
|
844
|
+
value: ''
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
textNode.value += v;
|
|
848
|
+
};
|
|
849
|
+
|
|
849
850
|
const flushText = () => {
|
|
850
851
|
if(!textNode) return;
|
|
851
852
|
parent.body.push(textNode);
|
|
@@ -910,10 +911,12 @@ function parse() {
|
|
|
910
911
|
}
|
|
911
912
|
continue;
|
|
912
913
|
} else if(a === '{') {
|
|
913
|
-
if(['#', '/', ':', '@'].indexOf(source[index + 1]) >= 0) {
|
|
914
|
-
flushText();
|
|
914
|
+
if(['#', '/', ':', '@', '*'].indexOf(source[index + 1]) >= 0) {
|
|
915
915
|
let bind = readBinding();
|
|
916
|
-
if(bind.value
|
|
916
|
+
if(bind.value[0] != '*') flushText();
|
|
917
|
+
if(bind.value[0] == '*') {
|
|
918
|
+
addText(bind.raw);
|
|
919
|
+
} else if(bind.value.match(/^@\w+/)) {
|
|
917
920
|
let tag = {
|
|
918
921
|
type: 'systag',
|
|
919
922
|
value: bind.value
|
|
@@ -1005,13 +1008,7 @@ function parse() {
|
|
|
1005
1008
|
}
|
|
1006
1009
|
}
|
|
1007
1010
|
|
|
1008
|
-
|
|
1009
|
-
textNode = {
|
|
1010
|
-
type: 'text',
|
|
1011
|
-
value: ''
|
|
1012
|
-
};
|
|
1013
|
-
}
|
|
1014
|
-
textNode.value += readNext();
|
|
1011
|
+
addText(readNext());
|
|
1015
1012
|
} flushText();
|
|
1016
1013
|
assert(parent.type === 'root', 'File ends to early');
|
|
1017
1014
|
};
|
package/malina.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
function toCamelCase(name) {
|
|
22
22
|
assert(name[name.length - 1] !== '-', 'Wrong name');
|
|
23
|
-
return name.replace(/(\-\w)/g, function(part) {
|
|
23
|
+
return name.replace(/(?<!-)(\-\w)/g, function(part) {
|
|
24
24
|
return part[1].toUpperCase();
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -56,19 +56,10 @@
|
|
|
56
56
|
let ast = acorn.parse(name, {allowReturnOutsideFunction: true});
|
|
57
57
|
|
|
58
58
|
function checkIdentificator(body) {
|
|
59
|
-
if(body.length != 1) return;
|
|
60
|
-
if(body[0].type != 'ExpressionStatement') return;
|
|
61
|
-
if(body[0].expression.type != 'Identifier') return;
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function checkMemberIdentificator(body) {
|
|
66
59
|
if(body.length != 1) return;
|
|
67
60
|
if(body[0].type != 'ExpressionStatement') return;
|
|
68
61
|
let obj = body[0].expression;
|
|
69
|
-
|
|
70
|
-
if(obj.property.type != 'Identifier') return;
|
|
71
|
-
return true;
|
|
62
|
+
return obj.type == 'Identifier' || obj.type == 'MemberExpression';
|
|
72
63
|
}
|
|
73
64
|
|
|
74
65
|
function checkFunction(body) {
|
|
@@ -80,7 +71,6 @@
|
|
|
80
71
|
}
|
|
81
72
|
|
|
82
73
|
if(checkIdentificator(ast.body)) return 'identifier';
|
|
83
|
-
if(checkMemberIdentificator(ast.body)) return 'identifier';
|
|
84
74
|
if(checkFunction(ast.body)) return 'function';
|
|
85
75
|
|
|
86
76
|
return;
|
|
@@ -830,7 +820,8 @@
|
|
|
830
820
|
} else continue;
|
|
831
821
|
|
|
832
822
|
return {
|
|
833
|
-
value: source.substring(start + 1, index - 1)
|
|
823
|
+
value: source.substring(start + 1, index - 1),
|
|
824
|
+
raw: source.substring(start, index)
|
|
834
825
|
};
|
|
835
826
|
}
|
|
836
827
|
};
|
|
@@ -847,6 +838,16 @@
|
|
|
847
838
|
const go = (parent) => {
|
|
848
839
|
let textNode = null;
|
|
849
840
|
|
|
841
|
+
const addText = v => {
|
|
842
|
+
if(!textNode) {
|
|
843
|
+
textNode = {
|
|
844
|
+
type: 'text',
|
|
845
|
+
value: ''
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
textNode.value += v;
|
|
849
|
+
};
|
|
850
|
+
|
|
850
851
|
const flushText = () => {
|
|
851
852
|
if(!textNode) return;
|
|
852
853
|
parent.body.push(textNode);
|
|
@@ -911,10 +912,12 @@
|
|
|
911
912
|
}
|
|
912
913
|
continue;
|
|
913
914
|
} else if(a === '{') {
|
|
914
|
-
if(['#', '/', ':', '@'].indexOf(source[index + 1]) >= 0) {
|
|
915
|
-
flushText();
|
|
915
|
+
if(['#', '/', ':', '@', '*'].indexOf(source[index + 1]) >= 0) {
|
|
916
916
|
let bind = readBinding();
|
|
917
|
-
if(bind.value
|
|
917
|
+
if(bind.value[0] != '*') flushText();
|
|
918
|
+
if(bind.value[0] == '*') {
|
|
919
|
+
addText(bind.raw);
|
|
920
|
+
} else if(bind.value.match(/^@\w+/)) {
|
|
918
921
|
let tag = {
|
|
919
922
|
type: 'systag',
|
|
920
923
|
value: bind.value
|
|
@@ -1006,13 +1009,7 @@
|
|
|
1006
1009
|
}
|
|
1007
1010
|
}
|
|
1008
1011
|
|
|
1009
|
-
|
|
1010
|
-
textNode = {
|
|
1011
|
-
type: 'text',
|
|
1012
|
-
value: ''
|
|
1013
|
-
};
|
|
1014
|
-
}
|
|
1015
|
-
textNode.value += readNext();
|
|
1012
|
+
addText(readNext());
|
|
1016
1013
|
} flushText();
|
|
1017
1014
|
assert(parent.type === 'root', 'File ends to early');
|
|
1018
1015
|
};
|
|
@@ -5891,7 +5888,7 @@
|
|
|
5891
5888
|
return {event, fn};
|
|
5892
5889
|
}
|
|
5893
5890
|
|
|
5894
|
-
const version = '0.6.
|
|
5891
|
+
const version = '0.6.54';
|
|
5895
5892
|
|
|
5896
5893
|
|
|
5897
5894
|
async function compile(source, config = {}) {
|
package/package.json
CHANGED
package/runtime.js
CHANGED
|
@@ -295,12 +295,12 @@ function $tick(fn, uniq) {
|
|
|
295
295
|
_tick_list.push(fn);
|
|
296
296
|
if(_tick_planned.$tick) return;
|
|
297
297
|
_tick_planned.$tick = true;
|
|
298
|
-
|
|
298
|
+
Promise.resolve().then(() => {
|
|
299
299
|
_tick_planned = {};
|
|
300
300
|
let list = _tick_list;
|
|
301
301
|
_tick_list = [];
|
|
302
302
|
list.map(safeCall);
|
|
303
|
-
}
|
|
303
|
+
});
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
function $makeEmitter(option) {
|
|
@@ -510,7 +510,7 @@ const bindText = (cd, element, fn) => {
|
|
|
510
510
|
|
|
511
511
|
const bindStyle = (cd, element, name, fn) => {
|
|
512
512
|
$watchReadOnly(cd, fn, (value) => {
|
|
513
|
-
element.style
|
|
513
|
+
element.style.setProperty(name, value);
|
|
514
514
|
});
|
|
515
515
|
};
|
|
516
516
|
|