@joker.front/core 1.2.139 → 1.2.141

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/dist/bundle.es.js CHANGED
@@ -1205,8 +1205,7 @@ var Render;
1205
1205
  }
1206
1206
  }
1207
1207
  else if (node instanceof VNode.Html) {
1208
- this.removeNode(node);
1209
- this.appendNode(node);
1208
+ node.output.root.innerHTML = node.html;
1210
1209
  }
1211
1210
  else {
1212
1211
  logger.error(LOGTAG$4, `该节点不支持${propertyKey}的更新`, node);
@@ -1333,7 +1332,9 @@ var Render;
1333
1332
  }
1334
1333
  }
1335
1334
  else if (node instanceof VNode.Html) {
1336
- node.output = this.parserHtml(node.html);
1335
+ let conatiner = document.createElement("joker-html-container");
1336
+ conatiner.root.innerHTML = node.html;
1337
+ node.output = conatiner;
1337
1338
  }
1338
1339
  else if (node instanceof VNode.Element) {
1339
1340
  let element;
@@ -1726,6 +1727,16 @@ function toMs(s) {
1726
1727
  return 0;
1727
1728
  return Number(s.slice(0, -1).replace(",", ".")) * 1000;
1728
1729
  }
1730
+ // 创建一个自定义元素
1731
+ class HtmlContainerWebComponent extends HTMLElement {
1732
+ root;
1733
+ constructor() {
1734
+ super();
1735
+ this.root = this.attachShadow({ mode: "open" });
1736
+ }
1737
+ }
1738
+ // 注册自定义元素
1739
+ customElements.define("joker-html-container", HtmlContainerWebComponent);
1729
1740
 
1730
1741
  //全局方法
1731
1742
  const __GLONAL_FUNTIONS__ = {};
@@ -2226,19 +2237,19 @@ class ParserCode extends IParser {
2226
2237
  logger.error("模板指令", "解析AST转换VNode时发生错误,未找到指令名称", this.ast);
2227
2238
  throw new Error("解析AST转换VNode时发生错误,未找到指令名称");
2228
2239
  }
2229
- let exporess = undefined;
2240
+ let express = undefined;
2230
2241
  //全局过滤器
2231
2242
  if (this.ast.cmdName === "Html" || this.ast.cmdName === "Text") {
2232
- exporess = this.ast.param;
2243
+ express = this.ast.param;
2233
2244
  }
2234
2245
  else if (this.ast.cmdName.startsWith(GLOBAL_TAG + ".")) {
2235
- exporess = `${this.ast.cmdName}(${this.ast.param})`;
2246
+ express = `${this.ast.cmdName}(${this.ast.param})`;
2236
2247
  }
2237
2248
  else if (this.ast.cmdName in this.ob && typeof this.ob[this.ast.cmdName] === "function") {
2238
- exporess = `${createFuntionBody(this.ast.cmdName)}(${this.ast.param})`;
2249
+ express = `${createFuntionBody(this.ast.cmdName)}(${this.ast.param})`;
2239
2250
  }
2240
- if (exporess) {
2241
- let data = this.runExpressWithWatcher(exporess, this.ob, (newVal) => {
2251
+ if (express) {
2252
+ let data = this.runExpressWithWatcher(express, this.ob, (newVal) => {
2242
2253
  if (this.node instanceof VNode.Html) {
2243
2254
  this.node.html = transformText(newVal);
2244
2255
  }
@@ -2250,6 +2261,7 @@ class ParserCode extends IParser {
2250
2261
  });
2251
2262
  data = transformText(data);
2252
2263
  if (this.ast.cmdName === "Html") {
2264
+ data ||= [];
2253
2265
  this.node = new VNode.Html(data, this.parent);
2254
2266
  }
2255
2267
  else {
package/dist/bundle.js CHANGED
@@ -1206,8 +1206,7 @@ var Render;
1206
1206
  }
1207
1207
  }
1208
1208
  else if (node instanceof exports.VNode.Html) {
1209
- this.removeNode(node);
1210
- this.appendNode(node);
1209
+ node.output.root.innerHTML = node.html;
1211
1210
  }
1212
1211
  else {
1213
1212
  logger.error(LOGTAG$4, `该节点不支持${propertyKey}的更新`, node);
@@ -1334,7 +1333,9 @@ var Render;
1334
1333
  }
1335
1334
  }
1336
1335
  else if (node instanceof exports.VNode.Html) {
1337
- node.output = this.parserHtml(node.html);
1336
+ let conatiner = document.createElement("joker-html-container");
1337
+ conatiner.root.innerHTML = node.html;
1338
+ node.output = conatiner;
1338
1339
  }
1339
1340
  else if (node instanceof exports.VNode.Element) {
1340
1341
  let element;
@@ -1727,6 +1728,16 @@ function toMs(s) {
1727
1728
  return 0;
1728
1729
  return Number(s.slice(0, -1).replace(",", ".")) * 1000;
1729
1730
  }
1731
+ // 创建一个自定义元素
1732
+ class HtmlContainerWebComponent extends HTMLElement {
1733
+ root;
1734
+ constructor() {
1735
+ super();
1736
+ this.root = this.attachShadow({ mode: "open" });
1737
+ }
1738
+ }
1739
+ // 注册自定义元素
1740
+ customElements.define("joker-html-container", HtmlContainerWebComponent);
1730
1741
 
1731
1742
  //全局方法
1732
1743
  const __GLONAL_FUNTIONS__ = {};
@@ -2227,19 +2238,19 @@ class ParserCode extends IParser {
2227
2238
  logger.error("模板指令", "解析AST转换VNode时发生错误,未找到指令名称", this.ast);
2228
2239
  throw new Error("解析AST转换VNode时发生错误,未找到指令名称");
2229
2240
  }
2230
- let exporess = undefined;
2241
+ let express = undefined;
2231
2242
  //全局过滤器
2232
2243
  if (this.ast.cmdName === "Html" || this.ast.cmdName === "Text") {
2233
- exporess = this.ast.param;
2244
+ express = this.ast.param;
2234
2245
  }
2235
2246
  else if (this.ast.cmdName.startsWith(GLOBAL_TAG + ".")) {
2236
- exporess = `${this.ast.cmdName}(${this.ast.param})`;
2247
+ express = `${this.ast.cmdName}(${this.ast.param})`;
2237
2248
  }
2238
2249
  else if (this.ast.cmdName in this.ob && typeof this.ob[this.ast.cmdName] === "function") {
2239
- exporess = `${ast.createFuntionBody(this.ast.cmdName)}(${this.ast.param})`;
2250
+ express = `${ast.createFuntionBody(this.ast.cmdName)}(${this.ast.param})`;
2240
2251
  }
2241
- if (exporess) {
2242
- let data = this.runExpressWithWatcher(exporess, this.ob, (newVal) => {
2252
+ if (express) {
2253
+ let data = this.runExpressWithWatcher(express, this.ob, (newVal) => {
2243
2254
  if (this.node instanceof exports.VNode.Html) {
2244
2255
  this.node.html = transformText(newVal);
2245
2256
  }
@@ -2251,6 +2262,7 @@ class ParserCode extends IParser {
2251
2262
  });
2252
2263
  data = transformText(data);
2253
2264
  if (this.ast.cmdName === "Html") {
2265
+ data ||= [];
2254
2266
  this.node = new exports.VNode.Html(data, this.parent);
2255
2267
  }
2256
2268
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joker.front/core",
3
- "version": "1.2.139",
3
+ "version": "1.2.141",
4
4
  "description": "",
5
5
  "main": "./dist/bundle.js",
6
6
  "module": "./dist/bundle.es.js",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "test": "jest",
23
- "test:temp": "jest test/parser/cmd.spec.ts",
23
+ "test:temp": "jest test/parser/html.spec.ts",
24
24
  "build": "joker_build_library --sourcemap=false",
25
25
  "release": "npm run test && npm run build && joker_release_library",
26
26
  "release:prod": "npm run test && npm run build && npm publish --access public --registry https://registry.npmjs.org/"