jquery-powertip icon indicating copy to clipboard operation
jquery-powertip copied to clipboard

Uncaught TypeError: Cannot read property 'data' of null

Open speedplane opened this issue 5 years ago • 3 comments

I'm running powertip 1.3.1 and got the following exception:

jquery.powertip.js:964 Uncaught TypeError: Cannot read property 'data' of null
    at hideTip (jquery.powertip.js:964)
    at showTip (jquery.powertip.js:855)
    at HTMLDivElement.queueTipInit (jquery.powertip.js:829)
    at Function.dequeue (js_thirdp_libs.js:20)
    at HTMLDivElement.r.complete (js_thirdp_libs.js:20)
    at l (js_thirdp_libs.js:20)
    at Object.fireWith [as resolveWith] (js_thirdp_libs.js:20)
    at a (js_thirdp_libs.js:20)
    at v.fx.tick (js_thirdp_libs.js:20)

This was occuring while I was hovering over something with a powerTip, and an event comes in which causes another powerTip to open. It's not entirely consistent, and I believe it has todo with the opening and closing state of the hovered powertip.

As shown in the debugger below, it looks like isTipOpen is true, and it isn't closing, but activeHover is null.

image

speedplane avatar Jul 27 '18 18:07 speedplane

Have you manage to solve it ?

george-dragnea avatar Sep 03 '18 10:09 george-dragnea

I apologize for the severely delayed response. I haven’t had much time to spend on personal projects lately.

This is very peculiar error indeed. This issue is very similar to issue #165, but the error is showing up at a different point in the script.

Other than the session object initialization, there is only one place in the code where session.activeHover is set to null:

// reset session and tooltip element
session.activeHover = null;
session.isClosing = false;
session.isFixedTipOpen = false;
tipElement.removeClass();

Which is in the fadeOut() completed callback in the hideTip() function. The session.isClosing property is set to true as soon as the hideTip() function is invoked to prevent exactly this situation. The hideTip() invocation in the debugger screen shot is wrapped in an if (!session.isClosing) check which is supposed to prevent erroneous repeated calls.

Based on the error, it looks like it failed at the element.data(DATA_HASACTIVEHOVER, false); line in the hideTip() function.

I’m not sure what’s going on here. I can think of a couple possibilities:

  • The hideTip method got called more than once for the previous element.
  • The hideTip method got called on the current element during the tooltip open.
  • The jQuery object that was passed to PowerTip got destroyed/garbage-collected unexpectedly.

But, without being able to see the code and debug it, I’m limited to guessing. I don’t see anything obvious that would allow this state to arise. I could add a session state check to the hideTip() function, but without knowing what the root cause is, I am hesitant to do so because it might just move the problem somewhere else and make it harder to debug the next time it arrises.

So I have a couple debugging questions:

  • Can you show me the code you’re using to run PowerTip? (Or provide a reduced test case/example that I can play with?)
  • Does this happen on other browsers?
  • What version of jQuery are you using?
  • Are the elements you’re adding tooltips to every dynamically added or removed from the page?

stevenbenner avatar Sep 23 '18 18:09 stevenbenner

@stevenbenner

Can you show me the code you’re using to run PowerTip? (Or provide a reduced test case/example that I can play with?)

.powerTip({ placement: 'se', intentPollInterval: 300 });

Does this happen on other browsers?

Chrome only

What version of jQuery are you using?

1.7.2

Are the elements you’re adding tooltips to every dynamically added or removed from the page?

Yes

yordis avatar May 26 '19 21:05 yordis