malinajs 0.6.57 → 0.6.58

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 (3) hide show
  1. package/compile.js +13 -6
  2. package/malina.js +14 -7
  3. package/package.json +1 -1
package/compile.js CHANGED
@@ -4025,7 +4025,10 @@ function makeDom(data) {
4025
4025
  let n = new Node(e.name, {__node: e});
4026
4026
  e.attributes.forEach(a => {
4027
4027
  if(a.name == 'class') {
4028
- if(a.value != null) n.className += ' ' + a.value;
4028
+ if(a.value != null) {
4029
+ if(a.value.includes('{')) n.dynClass = true;
4030
+ else n.className += ' ' + a.value;
4031
+ }
4029
4032
  n.attributes[a.name] = a.value;
4030
4033
  } else if(a.name == 'id') n.attributes.id = n.id = a.value;
4031
4034
  else if(a.name.startsWith('class:')) {
@@ -4102,12 +4105,16 @@ Node.prototype.getElementsByClassName = function(names) {
4102
4105
  if(names.length != 1) throw 'Not supported';
4103
4106
  let cls = names[0];
4104
4107
 
4108
+ let rx = RegExp('(^|\\s)' + cls + '(\\s|$)', 'i');
4105
4109
  let result = [];
4106
- this.childNodes.forEach(n => {
4107
- let rx = RegExp('(^|\\s)' + cls + '(\\s|$)', 'i');
4108
- if(rx.test(n.className)) result.push(n);
4109
- result.push.apply(result, n.getElementsByClassName(cls));
4110
- });
4110
+ const walk = (node) => {
4111
+ node.childNodes.forEach(n => {
4112
+ if(n.dynClass) result.push(n);
4113
+ else if(rx.test(n.className)) result.push(n);
4114
+ walk(n);
4115
+ });
4116
+ };
4117
+ walk(this);
4111
4118
  return result;
4112
4119
  };
4113
4120
 
package/malina.js CHANGED
@@ -4026,7 +4026,10 @@
4026
4026
  let n = new Node(e.name, {__node: e});
4027
4027
  e.attributes.forEach(a => {
4028
4028
  if(a.name == 'class') {
4029
- if(a.value != null) n.className += ' ' + a.value;
4029
+ if(a.value != null) {
4030
+ if(a.value.includes('{')) n.dynClass = true;
4031
+ else n.className += ' ' + a.value;
4032
+ }
4030
4033
  n.attributes[a.name] = a.value;
4031
4034
  } else if(a.name == 'id') n.attributes.id = n.id = a.value;
4032
4035
  else if(a.name.startsWith('class:')) {
@@ -4103,12 +4106,16 @@
4103
4106
  if(names.length != 1) throw 'Not supported';
4104
4107
  let cls = names[0];
4105
4108
 
4109
+ let rx = RegExp('(^|\\s)' + cls + '(\\s|$)', 'i');
4106
4110
  let result = [];
4107
- this.childNodes.forEach(n => {
4108
- let rx = RegExp('(^|\\s)' + cls + '(\\s|$)', 'i');
4109
- if(rx.test(n.className)) result.push(n);
4110
- result.push.apply(result, n.getElementsByClassName(cls));
4111
- });
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);
4112
4119
  return result;
4113
4120
  };
4114
4121
 
@@ -5917,7 +5924,7 @@
5917
5924
  return {event, fn};
5918
5925
  }
5919
5926
 
5920
- const version = '0.6.57';
5927
+ const version = '0.6.58';
5921
5928
 
5922
5929
 
5923
5930
  async function compile(source, config = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "malinajs",
3
- "version": "0.6.57",
3
+ "version": "0.6.58",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "prepare": "npm run build",