mirror of
https://github.com/element-plus/element-plus.git
synced 2025-12-19 09:09:40 +08:00
fix(components): [text] the title attribute loses its reactivity (#20875)
This commit is contained in:
@@ -34,12 +34,13 @@ const textKls = computed(() => [
|
||||
ns.is('line-clamp', !isUndefined(props.lineClamp)),
|
||||
])
|
||||
|
||||
const inheritTitle = useAttrs().title
|
||||
|
||||
const bindTitle = () => {
|
||||
const inheritTitle = useAttrs().title
|
||||
|
||||
if (inheritTitle) return
|
||||
let shouldAddTitle = false
|
||||
const text = textRef.value?.textContent || ''
|
||||
|
||||
if (props.truncated) {
|
||||
const width = textRef.value?.offsetWidth
|
||||
const scrollWidth = textRef.value?.scrollWidth
|
||||
@@ -53,6 +54,7 @@ const bindTitle = () => {
|
||||
shouldAddTitle = true
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldAddTitle) {
|
||||
textRef.value?.setAttribute('title', text)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user