@@ -82,7 +82,7 @@ export function pillifyLinks(nodes: ArrayLike<Element>, mxEvent: MatrixEvent, pi
82
82
) ;
83
83
84
84
ReactDOM . render ( pill , pillContainer ) ;
85
- node . parentNode . replaceChild ( pillContainer , node ) ;
85
+ node . parentNode ? .replaceChild ( pillContainer , node ) ;
86
86
pills . push ( pillContainer ) ;
87
87
// Pills within pills aren't going to go well, so move on
88
88
pillified = true ;
@@ -95,10 +95,10 @@ export function pillifyLinks(nodes: ArrayLike<Element>, mxEvent: MatrixEvent, pi
95
95
// as applying pills happens outside of react, make sure we're not doubly
96
96
// applying @room pills here, as a rerender with the same content won't touch the DOM
97
97
// to clear the pills from the last run of pillifyLinks
98
- ! node . parentElement . classList . contains ( "mx_AtRoomPill" )
98
+ ! node . parentElement ? .classList . contains ( "mx_AtRoomPill" )
99
99
) {
100
100
let currentTextNode = node as Node as Text | null ;
101
- const roomNotifTextNodes = [ ] ;
101
+ const roomNotifTextNodes : Text [ ] = [ ] ;
102
102
103
103
// Take a textNode and break it up to make all the instances of @room their
104
104
// own textNode, adding those nodes to roomNotifTextNodes
@@ -109,7 +109,7 @@ export function pillifyLinks(nodes: ArrayLike<Element>, mxEvent: MatrixEvent, pi
109
109
let roomTextNode = currentTextNode ;
110
110
111
111
if ( roomNotifPos > 0 ) roomTextNode = roomTextNode . splitText ( roomNotifPos ) ;
112
- if ( roomTextNode . textContent . length > pillRoomNotifLen ( ) ) {
112
+ if ( roomTextNode . textContent && roomTextNode . textContent . length > pillRoomNotifLen ( ) ) {
113
113
nextTextNode = roomTextNode . splitText ( pillRoomNotifLen ( ) ) ;
114
114
}
115
115
roomNotifTextNodes . push ( roomTextNode ) ;
@@ -140,7 +140,7 @@ export function pillifyLinks(nodes: ArrayLike<Element>, mxEvent: MatrixEvent, pi
140
140
) ;
141
141
142
142
ReactDOM . render ( pill , pillContainer ) ;
143
- roomNotifTextNode . parentNode . replaceChild ( pillContainer , roomNotifTextNode ) ;
143
+ roomNotifTextNode . parentNode ? .replaceChild ( pillContainer , roomNotifTextNode ) ;
144
144
pills . push ( pillContainer ) ;
145
145
}
146
146
// Nothing else to do for a text node (and we don't need to advance
0 commit comments