malinajs 0.6.56 → 0.6.59
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 +18 -10
- package/malina.js +19 -11
- package/package.json +1 -1
package/compile.js
CHANGED
|
@@ -18,9 +18,10 @@ function assert(x, info) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function toCamelCase(name) {
|
|
21
|
-
assert(name
|
|
22
|
-
return name.replace(/(
|
|
23
|
-
|
|
21
|
+
assert(last(name) !== '-', 'Wrong name');
|
|
22
|
+
return name.replace(/(.\-\w)/g, function(part) {
|
|
23
|
+
if(part[0] == '-') return part;
|
|
24
|
+
return part[0] + part[2].toUpperCase();
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
function Q(s) {
|
|
@@ -1247,7 +1248,7 @@ function transform() {
|
|
|
1247
1248
|
function walk(node, parent, fn) {
|
|
1248
1249
|
if(typeof node !== 'object') return;
|
|
1249
1250
|
|
|
1250
|
-
if(node._apply) return;
|
|
1251
|
+
if(node._apply && node.type == 'ExpressionStatement') return;
|
|
1251
1252
|
node._parent = parent;
|
|
1252
1253
|
let forParent = parent;
|
|
1253
1254
|
if(node.type) {
|
|
@@ -4025,7 +4026,10 @@ function makeDom(data) {
|
|
|
4025
4026
|
let n = new Node(e.name, {__node: e});
|
|
4026
4027
|
e.attributes.forEach(a => {
|
|
4027
4028
|
if(a.name == 'class') {
|
|
4028
|
-
if(a.value != null)
|
|
4029
|
+
if(a.value != null) {
|
|
4030
|
+
if(a.value.includes('{')) n.dynClass = true;
|
|
4031
|
+
else n.className += ' ' + a.value;
|
|
4032
|
+
}
|
|
4029
4033
|
n.attributes[a.name] = a.value;
|
|
4030
4034
|
} else if(a.name == 'id') n.attributes.id = n.id = a.value;
|
|
4031
4035
|
else if(a.name.startsWith('class:')) {
|
|
@@ -4102,12 +4106,16 @@ Node.prototype.getElementsByClassName = function(names) {
|
|
|
4102
4106
|
if(names.length != 1) throw 'Not supported';
|
|
4103
4107
|
let cls = names[0];
|
|
4104
4108
|
|
|
4109
|
+
let rx = RegExp('(^|\\s)' + cls + '(\\s|$)', 'i');
|
|
4105
4110
|
let result = [];
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
+
const walk = (node) => {
|
|
4112
|
+
node.childNodes.forEach(n => {
|
|
4113
|
+
if(n.dynClass) result.push(n);
|
|
4114
|
+
else if(rx.test(n.className)) result.push(n);
|
|
4115
|
+
walk(n);
|
|
4116
|
+
});
|
|
4117
|
+
};
|
|
4118
|
+
walk(this);
|
|
4111
4119
|
return result;
|
|
4112
4120
|
};
|
|
4113
4121
|
|
package/malina.js
CHANGED
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function toCamelCase(name) {
|
|
22
|
-
assert(name
|
|
23
|
-
return name.replace(/(
|
|
24
|
-
|
|
22
|
+
assert(last(name) !== '-', 'Wrong name');
|
|
23
|
+
return name.replace(/(.\-\w)/g, function(part) {
|
|
24
|
+
if(part[0] == '-') return part;
|
|
25
|
+
return part[0] + part[2].toUpperCase();
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
function Q(s) {
|
|
@@ -1248,7 +1249,7 @@
|
|
|
1248
1249
|
function walk(node, parent, fn) {
|
|
1249
1250
|
if(typeof node !== 'object') return;
|
|
1250
1251
|
|
|
1251
|
-
if(node._apply) return;
|
|
1252
|
+
if(node._apply && node.type == 'ExpressionStatement') return;
|
|
1252
1253
|
node._parent = parent;
|
|
1253
1254
|
let forParent = parent;
|
|
1254
1255
|
if(node.type) {
|
|
@@ -4026,7 +4027,10 @@
|
|
|
4026
4027
|
let n = new Node(e.name, {__node: e});
|
|
4027
4028
|
e.attributes.forEach(a => {
|
|
4028
4029
|
if(a.name == 'class') {
|
|
4029
|
-
if(a.value != null)
|
|
4030
|
+
if(a.value != null) {
|
|
4031
|
+
if(a.value.includes('{')) n.dynClass = true;
|
|
4032
|
+
else n.className += ' ' + a.value;
|
|
4033
|
+
}
|
|
4030
4034
|
n.attributes[a.name] = a.value;
|
|
4031
4035
|
} else if(a.name == 'id') n.attributes.id = n.id = a.value;
|
|
4032
4036
|
else if(a.name.startsWith('class:')) {
|
|
@@ -4103,12 +4107,16 @@
|
|
|
4103
4107
|
if(names.length != 1) throw 'Not supported';
|
|
4104
4108
|
let cls = names[0];
|
|
4105
4109
|
|
|
4110
|
+
let rx = RegExp('(^|\\s)' + cls + '(\\s|$)', 'i');
|
|
4106
4111
|
let result = [];
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
+
const walk = (node) => {
|
|
4113
|
+
node.childNodes.forEach(n => {
|
|
4114
|
+
if(n.dynClass) result.push(n);
|
|
4115
|
+
else if(rx.test(n.className)) result.push(n);
|
|
4116
|
+
walk(n);
|
|
4117
|
+
});
|
|
4118
|
+
};
|
|
4119
|
+
walk(this);
|
|
4112
4120
|
return result;
|
|
4113
4121
|
};
|
|
4114
4122
|
|
|
@@ -5917,7 +5925,7 @@
|
|
|
5917
5925
|
return {event, fn};
|
|
5918
5926
|
}
|
|
5919
5927
|
|
|
5920
|
-
const version = '0.6.
|
|
5928
|
+
const version = '0.6.59';
|
|
5921
5929
|
|
|
5922
5930
|
|
|
5923
5931
|
async function compile(source, config = {}) {
|