hy-virtual-tree 2.0.7 → 2.0.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.0.8
4
+
5
+ _2026-03-17_
6
+
7
+ (1)修复自定义元素插槽传入元素节点时没有正常渲染bug
8
+
3
9
  ### 2.0.7
4
10
 
5
11
  _2026-03-16_
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* hy-virtual-tree v2.0.7 */
1
+ /* hy-virtual-tree v2.0.8 */
2
2
  import './svg_bundle.js';
3
3
  const isString = (e) => typeof e === 'string';
4
4
  const isNumber = (e) => typeof e === 'number';
@@ -9024,7 +9024,7 @@ const generateStats = (data, node) => {
9024
9024
  };
9025
9025
  // 自定义渲染元素
9026
9026
  const customRender = (options) => {
9027
- const { fn, node, parent, className, defaultFn, inset = false } = options || {};
9027
+ const { fn, node, parent, className, defaultFn } = options || {};
9028
9028
  let value;
9029
9029
  // 没有传入的自定义函数则使用默认函数
9030
9030
  if (!fn || !isFunction(fn)) {
@@ -9054,32 +9054,14 @@ const customRender = (options) => {
9054
9054
  return value;
9055
9055
  }
9056
9056
  else if (isElement(value)) {
9057
- if (inset) {
9058
- return createVNode('div', (vnode) => {
9059
- className && vnode.el.classList.add(className);
9060
- vnode.el.appendChild(value);
9061
- });
9062
- }
9063
- else {
9064
- className && value.classList.add(className);
9057
+ return createVNode('div', (vnode) => {
9058
+ className && vnode.el.classList.add(className);
9059
+ vnode.el.appendChild(value);
9060
+ vnode.$destroy = value.$destroy;
9065
9061
  if (parent) {
9066
- if (parent.el) {
9067
- parent.el.appendChild(value);
9068
- }
9069
- const target = {
9070
- el: value,
9071
- destroy: () => {
9072
- // @ts-ignore
9073
- value && value.$destroy && value.$destroy();
9074
- // @ts-ignore
9075
- value && value.destroy && value.destroy();
9076
- }
9077
- };
9078
- if (!parent.children)
9079
- parent.children = [];
9080
- parent.children.push(target);
9062
+ vnode.mount(parent);
9081
9063
  }
9082
- }
9064
+ });
9083
9065
  }
9084
9066
  if (isEmpty(value))
9085
9067
  return;
@@ -9776,7 +9758,6 @@ class VirtualTree {
9776
9758
  statusSlot = customRender({
9777
9759
  fn: config.renderStatus,
9778
9760
  node: item,
9779
- inset: true,
9780
9761
  className: 'hy-tree-node__status',
9781
9762
  defaultFn: (data, node) => {
9782
9763
  return useStatus(config, data);
@@ -9784,7 +9765,7 @@ class VirtualTree {
9784
9765
  });
9785
9766
  }
9786
9767
  // 右侧内容
9787
- rightSlot = customRender({ fn: config.renderRight, node: item, inset: true, className: 'hy-tree-node__right-content' });
9768
+ rightSlot = customRender({ fn: config.renderRight, node: item, className: 'hy-tree-node__right-content' });
9788
9769
  if (!statusSlot && !rightSlot)
9789
9770
  return;
9790
9771
  return createVNode('div', (vnode) => {
@@ -9895,14 +9876,13 @@ class VirtualTree {
9895
9876
  customRender({
9896
9877
  fn: config.renderItem,
9897
9878
  node: item,
9898
- inset: true,
9899
9879
  parent: contentContainer,
9900
9880
  className: 'hy-tree-node__node-content',
9901
9881
  defaultFn: (data, node) => {
9902
9882
  // 图标
9903
- customRender({ fn: config.renderIcon, node, inset: true, parent: contentContainer, className: 'hy-tree-icon', defaultFn: generateIcon });
9883
+ customRender({ fn: config.renderIcon, node, parent: contentContainer, className: 'hy-tree-icon', defaultFn: generateIcon });
9904
9884
  // 内容
9905
- customRender({ fn: config.renderContent, node, inset: true, parent: contentContainer, className: 'hy-tree-node__content', defaultFn: useContent });
9885
+ customRender({ fn: config.renderContent, node, parent: contentContainer, className: 'hy-tree-node__content', defaultFn: useContent });
9906
9886
  // 统计
9907
9887
  if (isShowCount(this._props.showCount, item)) {
9908
9888
  customRender({ fn: generateStats, node, parent: contentContainer });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hy-virtual-tree",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",