DOM 1.6.0. Uncaught TypeError: Cannot read property 'tagName' of null

1,046 views
Skip to first unread message

Wojciech Makowiecki

unread,
Feb 28, 2014, 12:01:13 PM2/28/14
to jsp...@googlegroups.com
  1. Hi,

I'm getting this in the newest dev version.

  1. Uncaught TypeError: Cannot read property 'tagName' of null dom.jsPlumb-1.6.0.js:909
    1. jsPlumb.extend.offdom.jsPlumb-1.6.0.js:11117
    2. window.jsPlumbInstance.unregisterListenerdom.jsPlumb-1.6.0.js:4970
    3. window.jsPlumbInstance.unmakeSourcedom.jsPlumb-1.6.0.js:4782
    4. window.jsPlumbInstance.unmakeEverySourcedom.jsPlumb-1.6.0.js:4794

  2. Best,
  3. Wojciech

Simon Porritt

unread,
Feb 28, 2014, 2:16:16 PM2/28/14
to jsp...@googlegroups.com

This isn't very useful without some context....

Simon Porritt

unread,
Feb 28, 2014, 2:19:47 PM2/28/14
to jsp...@googlegroups.com

...but of course the stack shows the original call. Ok. I will take a look.

Simon Porritt

unread,
Feb 28, 2014, 2:56:35 PM2/28/14
to jsp...@googlegroups.com
i cant reproduce in my unit tests. perhaps you could post a test case?

Wojciech Makowiecki

unread,
Feb 28, 2014, 3:37:35 PM2/28/14
to jsp...@googlegroups.com
It's difficult to put it in the fiddle
so let me describe what I'm doing.

1. I'm detaching all connections that have a source or target at #node_id
element by using jsPlumb.detach(connection);

2. I'm deleting that node from DOM $("#node_id").remove();

3. I'm using jsPlumb.unmakeEverySource(); // and here comes the error

It worked fine on previous versions of jsPlumb,
so it has to do with 1.6.0. DOM


On Fri, Feb 28, 2014 at 8:56 PM, Simon Porritt <simon....@gmail.com> wrote:
i cant reproduce in my unit tests. perhaps you could post a test case?

--
You received this message because you are subscribed to the Google Groups "jsPlumb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsplumb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Simon Porritt

unread,
Feb 28, 2014, 4:28:55 PM2/28/14
to jsp...@googlegroups.com

If you’re not using jsPlumb.remove, which you should do when you want to remove an element from the DOM and have it cleaned up, then yes, jQuery-based versions of jsPlumb would not have thrown the error, as jQuery’s selector stuff glosses over the case that you try to perform an operation on an empty set. Well perhaps “glosses over” is unfair, because in most cases it’s very useful. Either way, it doesn’t crash.

In this case you’ve removed the element from the DOM and then subsequently asked jsPlumb to unregister a bunch of event listeners from it (that’s what unmakeSource does, basically). Since it doesn’t exist anymore, and Mottle - the new library I’m using for events - doesn’t expect null as an argument, you see this error.

I will update Mottle to gracefully handle null input. But I’d recommend to you to switch to using jsPlumb.remove anyway.

Wojciech Makowiecki

unread,
Feb 28, 2014, 4:34:53 PM2/28/14
to jsp...@googlegroups.com
Aha! Thank you Simon! 
No, I wasn't using jsPlumb.remove,
I will update my code and let you know how that goes!


--

Wojciech Makowiecki

unread,
Mar 1, 2014, 4:18:31 PM3/1/14
to jsp...@googlegroups.com
So I used:

jsPlumb.remove($(elem_to_remove));

It removed the element, all of its connections and even arrows pointing to labels of these connections, which is all very good,
but I'm still getting exactly the same error as before when I use jsPlumb.unmakeEverySource();
after running jsPlumb.remove();

Would you have other suggestions ?

Simon Porritt

unread,
Mar 1, 2014, 4:33:21 PM3/1/14
to jsp...@googlegroups.com

I've updated the beta versions of 1.6.0. Grab the latest...

Wojciech Makowiecki

unread,
Mar 1, 2014, 4:33:59 PM3/1/14
to jsp...@googlegroups.com
Great, thanks!


On Sat, Mar 1, 2014 at 10:33 PM, Simon Porritt <simon....@gmail.com> wrote:

I've updated the beta versions of 1.6.0. Grab the latest...

--

Wojciech Makowiecki

unread,
Mar 1, 2014, 4:44:39 PM3/1/14
to jsp...@googlegroups.com
Hm, I'm getting the same error :(

Simon Porritt

unread,
Mar 1, 2014, 4:52:27 PM3/1/14
to jsp...@googlegroups.com

You might have to put together a fiddle then.

Wojciech Makowiecki

unread,
Mar 1, 2014, 5:18:52 PM3/1/14
to jsp...@googlegroups.com
I'll see what I can do, but for now will just catch the error,
as I have one deadline approaching.


On Sat, Mar 1, 2014 at 10:52 PM, Simon Porritt <simon....@gmail.com> wrote:

You might have to put together a fiddle then.

--

Simon Porritt

unread,
Mar 1, 2014, 6:49:29 PM3/1/14
to jsp...@googlegroups.com

No problem.

Wojciech Makowiecki

unread,
Mar 3, 2014, 8:47:24 AM3/3/14
to jsp...@googlegroups.com
I'm getting the same error by calling another function (different stack as well)

  1. Uncaught TypeError: Cannot read property 'tagName' of null dom.jsPlumb-1.6.0.js:3338
    1. _getParentFromParamsdom.jsPlumb-1.6.0.js:3338


On Sunday, March 2, 2014 12:49:29 AM UTC+1, simon....@gmail.com wrote:

No problem.

Wojciech Makowiecki

unread,
Mar 3, 2014, 9:34:09 AM3/3/14
to jsp...@googlegroups.com
I figured out that this happened because I was trying to add an endpoint
to a div that didn't exist at that time.


--
Reply all
Reply to author
Forward
0 new messages