malinajs 0.7.16 → 0.7.18

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/malina.js +24 -6
  2. package/package.json +1 -1
package/malina.js CHANGED
@@ -972,7 +972,21 @@
972
972
  function parseHTML(source) {
973
973
  const reader = new Reader(source);
974
974
 
975
- const readScript = (reader) => {
975
+ const readScript = (reader, tag) => {
976
+ tag.type = 'script';
977
+
978
+ let isJS = true;
979
+ for (let a of tag.attributes) {
980
+ if (a.name == 'lang' || a.name == 'language' || a.name == 'type') {
981
+ isJS = a.value.indexOf('javascript') >= 0 || a.value.indexOf('ecmascript') >= 0;
982
+ tag.lang = a.value;
983
+ break;
984
+ }
985
+ }
986
+ tag.content = isJS ? readScriptJS(reader) : readScriptRaw();
987
+ };
988
+
989
+ const readScriptJS = (reader) => {
976
990
  class ScriptParser extends acorn__default["default"].Parser {
977
991
  readToken_lt_gt(code) {
978
992
  if (this.input.slice(this.pos, this.pos + 9) == '</script>') {
@@ -997,6 +1011,10 @@
997
1011
  return reader.sub(start, end);
998
1012
  };
999
1013
 
1014
+ const readScriptRaw = () => {
1015
+ return reader.read(/^(.*?)<\/script>/s);
1016
+ };
1017
+
1000
1018
  const readStyle = () => {
1001
1019
  return reader.read(/^(.*?)<\/style>/s);
1002
1020
  };
@@ -1054,8 +1072,7 @@
1054
1072
  let tag = readTag(reader);
1055
1073
  push(tag);
1056
1074
  if(tag.name === 'script') {
1057
- tag.type = 'script';
1058
- tag.content = readScript(reader);
1075
+ readScript(reader, tag);
1059
1076
  continue;
1060
1077
  } else if(tag.name === 'template') {
1061
1078
  tag.type = 'template';
@@ -5194,17 +5211,18 @@
5194
5211
  return;
5195
5212
  } else if(this.config.passClass && (name == 'class' || name.startsWith('class:'))) {
5196
5213
  let metaClass, args = name.split(':');
5197
- if(args.length == 1) {
5214
+ if (args.length == 1) {
5198
5215
  metaClass = '$$main';
5199
5216
  } else {
5200
5217
  assert(args.length == 2);
5201
5218
  metaClass = args[1];
5202
5219
  assert(metaClass);
5220
+ if (!value) value = metaClass;
5203
5221
  }
5204
5222
  assert(value);
5205
5223
  this.css.passingClass = true;
5206
5224
 
5207
- const parsed = this.parseText(prop.value);
5225
+ const parsed = this.parseText(value);
5208
5226
  this.detectDependency(parsed);
5209
5227
  let exp = parsed.result;
5210
5228
  $class.push(`${metaClass}: $$resolveClass(${exp})`);
@@ -6887,7 +6905,7 @@
6887
6905
  });
6888
6906
  }
6889
6907
 
6890
- const version = '0.7.16';
6908
+ const version = '0.7.18';
6891
6909
 
6892
6910
 
6893
6911
  async function compile(source, config = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "malinajs",
3
- "version": "0.7.16",
3
+ "version": "0.7.18",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "build": "npm run build_runtime && rollup -c",