@@ -133,17 +133,19 @@ const TooltipController = ({
133
133
return ( ) => null
134
134
}
135
135
136
+ const anchorElement = activeAnchor . current ?? anchorById
137
+
136
138
const observerCallback : MutationCallback = ( mutationList ) => {
137
139
mutationList . forEach ( ( mutation ) => {
138
140
if (
139
- ! activeAnchor . current ||
141
+ ! anchorElement ||
140
142
mutation . type !== 'attributes' ||
141
143
! mutation . attributeName ?. startsWith ( 'data-tooltip-' )
142
144
) {
143
145
return
144
146
}
145
147
// make sure to get all set attributes, since all unset attributes are reset
146
- const dataAttributes = getDataAttributesFromAnchorElement ( activeAnchor . current )
148
+ const dataAttributes = getDataAttributesFromAnchorElement ( anchorElement )
147
149
applyAllDataAttributesFromAnchorElement ( dataAttributes )
148
150
} )
149
151
}
@@ -155,13 +157,11 @@ const TooltipController = ({
155
157
// to stay watching `data-attributes-*` from anchor element
156
158
const observerConfig = { attributes : true , childList : false , subtree : false }
157
159
158
- const element = activeAnchor . current ?? anchorById
159
-
160
- if ( element ) {
161
- const dataAttributes = getDataAttributesFromAnchorElement ( element )
160
+ if ( anchorElement ) {
161
+ const dataAttributes = getDataAttributesFromAnchorElement ( anchorElement )
162
162
applyAllDataAttributesFromAnchorElement ( dataAttributes )
163
163
// Start observing the target node for configured mutations
164
- observer . observe ( element , observerConfig )
164
+ observer . observe ( anchorElement , observerConfig )
165
165
}
166
166
167
167
return ( ) => {
0 commit comments