Skip to content

Commit b96db94

Browse files
committed
fix(tooltip): more secure execution of the renderContent function
1 parent fff845b commit b96db94

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

packages/vue/src/tooltip/src/mobile-first.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ export default defineComponent({
115115
let attrContent
116116
117117
if (vm.renderContent) {
118-
attrContent = vm.renderContent(h, vm.content)
118+
try {
119+
attrContent = vm.renderContent(h, vm.content)
120+
} catch (e) {
121+
console.warn('[TINY Error] renderContent catch error:', e)
122+
attrContent = vm.content || null
123+
}
119124
} else if (vm.pre) {
120125
attrContent = vm.content ? h('pre', { class: 'tiny-tooltip-text-pre whitespace-pre-wrap' }, vm.content) : null
121126
} else {

packages/vue/src/tooltip/src/pc.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ export default defineComponent({
133133
let attrContent: any
134134
135135
if (vm.renderContent) {
136-
attrContent = vm.renderContent(h, vm.content)
136+
try {
137+
attrContent = vm.renderContent(h, vm.content)
138+
} catch (e) {
139+
console.warn('[TINY Error] renderContent catch error:', e)
140+
attrContent = vm.content || null
141+
}
137142
} else if (vm.pre) {
138143
attrContent = vm.content ? h('pre', vm.content) : null
139144
} else {

0 commit comments

Comments
 (0)