mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-27 03:01:14 +08:00
fix: 'textContent' of undefined and text wrapping (#1973)
This commit is contained in:
parent
79876b9733
commit
aca8a21f79
@ -48,7 +48,7 @@ export default defineComponent({
|
||||
if (!content) return
|
||||
const h3 = content.querySelectorAll('h3')
|
||||
anchors.value = Array.from(h3).map(item => {
|
||||
const text = item.childNodes[1].textContent.trim()
|
||||
const text = item.childNodes[1] && item.childNodes[1].textContent.trim()
|
||||
map.set(text, item.offsetTop)
|
||||
return text
|
||||
})
|
||||
@ -57,7 +57,7 @@ export default defineComponent({
|
||||
let mapKeys = Array.from(map.keys()).reverse()
|
||||
resizeObserver = new ResizeObserver(() => {
|
||||
Array.from(h3).forEach(item => {
|
||||
const text = item.childNodes[1].textContent.trim()
|
||||
const text = item.childNodes[1] && item.childNodes[1].textContent.trim()
|
||||
map.set(text, item.offsetTop)
|
||||
})
|
||||
mapValues = Array.from(map.values()).reverse()
|
||||
|
@ -214,6 +214,10 @@ export default {
|
||||
position: relative;
|
||||
transition: .15s ease-out;
|
||||
font-weight: bold;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
font-weight: normal;
|
||||
|
||||
&.active {
|
||||
color: #409EFF;
|
||||
|
Loading…
Reference in New Issue
Block a user