@@ -105,8 +105,10 @@ const restorePinnedTips = () => {
105105}
106106
107107export function hideAll ( ) {
108- state . tips . forEach ( ( { tip} , target ) =>
109- tip . style . display = 'none' )
108+ state . tips . forEach ( ( { tip} , target ) => {
109+ if ( tip )
110+ tip . style . display = 'none'
111+ } )
110112
111113 if ( state . active . tip ) {
112114 state . active . tip . remove ( )
@@ -116,10 +118,13 @@ export function hideAll() {
116118
117119export function removeAll ( ) {
118120 state . tips . forEach ( ( { tip} , target ) => {
119- tip . remove ( )
121+ tip && tip . remove ( )
120122 unobserve ( { tip, target} )
121123 } )
122124
125+ $ ( 'visbug-allytip' ) . forEach ( tip =>
126+ tip . remove ( ) )
127+
123128 $ ( '[data-allytip]' ) . attr ( 'data-allytip' , null )
124129
125130 state . tips . clear ( )
@@ -209,19 +214,22 @@ const wipe = ({tip, e:{target}}) => {
209214const togglePinned = els => {
210215 if ( state . restoring ) return state . restoring = false
211216
212- els . forEach ( el => {
213- if ( ! el . hasAttribute ( 'data-allytip' ) ) {
217+ state . tips . forEach ( ally => {
218+ if ( ! els . includes ( ally . e . target ) ) {
219+ ally . e . target . removeAttribute ( 'data-allytip' )
220+ wipe ( state . tips . get ( ally . e . target ) )
221+ }
222+ } )
223+
224+ els
225+ . filter ( el => ! el . hasAttribute ( 'data-allytip' ) )
226+ . forEach ( el => {
214227 el . setAttribute ( 'data-allytip' , true )
215228 state . tips . set ( el , {
216229 tip : state . active . tip ,
217230 e : { target :el } ,
218231 } )
219232 clearActive ( )
220- }
221- else if ( el . hasAttribute ( 'data-allytip' ) ) {
222- el . removeAttribute ( 'data-allytip' )
223- wipe ( state . tips . get ( el ) )
224- }
225233 } )
226234}
227235
0 commit comments