Skip to content

Commit

Permalink
fix: VClick component with table element
Browse files Browse the repository at this point in the history
  • Loading branch information
kermanx committed May 21, 2024
1 parent cf2fee4 commit 8c0a9ec
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
1 change: 1 addition & 0 deletions packages/client/builtin/VClick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default defineComponent({
at: this.at,
hide: this.hide,
fade: this.fade,
handleSpecialElements: false,
},
{
default: () =>
Expand Down
36 changes: 21 additions & 15 deletions packages/client/builtin/VClicks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export default defineComponent({
type: Boolean,
default: false,
},
handleSpecialElements: {
type: Boolean,
default: true,
},
},
render() {
const every = +this.every
Expand Down Expand Up @@ -120,21 +124,23 @@ export default defineComponent({
size: +at + Math.ceil((globalIdx - 1) / every) - 1 - execIdx,
})

// handle ul, ol list
if (elements.length === 1 && listTags.includes(elements[0].type as string) && Array.isArray(elements[0].children))
return h(elements[0], {}, [...mapChildren(elements[0].children), lastGap()])

if (elements.length === 1 && elements[0].type as string === 'table') {
const tableNode = elements[0]
if (Array.isArray(tableNode.children)) {
return h(tableNode, {}, tableNode.children.map((i) => {
if (!isVNode(i))
return i
else if (i.type === 'tbody' && Array.isArray(i.children))
return h(i, {}, [...mapChildren(i.children), lastGap()])
else
return h(i)
}))
if (this.handleSpecialElements) {
// handle ul, ol list
if (elements.length === 1 && listTags.includes(elements[0].type as string) && Array.isArray(elements[0].children))
return h(elements[0], {}, [...mapChildren(elements[0].children), lastGap()])

if (elements.length === 1 && elements[0].type as string === 'table') {
const tableNode = elements[0]
if (Array.isArray(tableNode.children)) {
return h(tableNode, {}, tableNode.children.map((i) => {
if (!isVNode(i))
return i
else if (i.type === 'tbody' && Array.isArray(i.children))
return h(i, {}, [...mapChildren(i.children), lastGap()])
else
return h(i)
}))
}
}
}

Expand Down

0 comments on commit 8c0a9ec

Please sign in to comment.