question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fade(false) fails with "TypeError: element.attr(...) is null"

See original GitHub issue

I’m trying to disable fading, but if I call fade(false) the render function fails. The following example is based on the latest 3.0.1 version, but I had a similar exception with 2.6.1 as well.

Easiest way to reproduce: Apply the following patch to examples/basic-add-edge.html

diff --git a/examples/basic-add-edge.html b/examples/basic-add-edge.html
index e83677e..783630c 100644
--- a/examples/basic-add-edge.html
+++ b/examples/basic-add-edge.html
@@ -24,6 +24,7 @@ var dotSrc = `strict digraph {
 }`;
 
 var graphviz = d3.select("#graph").graphviz()
+    .fade(false)
     .attributer(attributer)
     .transition(function() {
         return d3.transition().duration(1000);

The following is shown in the log:

TypeError: element.attr(...) is null element.js:36:29
    extractElementData element.js:36
    attributeElement render.js:171
    selection_each d3.js:1176
    insertChildren render.js:103
    attributeElement render.js:329
    selection_each d3.js:1176
    insertChildren render.js:103
    attributeElement render.js:329
    _render render.js:386
    render render.js:24
    <anonymous> self-hosted:876
    1 d3.js:3232
    timerFlush d3.js:3176
    wake d3.js:3186

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
nggcommented, Mar 10, 2020

Thanks for the quick fix, it solves the original occurrence of this bug as well.

1reaction
magjaccommented, Mar 9, 2020

Thanks. Can you confirm that the .tweenShapes(false) workaround avoids the problem in your application?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Cannot read property of null - iDiallo
This error occurs when you read a property or call a method on a null object . That's because the DOM API returns...
Read more >
Uncaught TypeError: Cannot read property 'add' of null #1953
Thrown on every "resize" Event. 4 Slides, Using the following options: { arrows: true, dots: true, adaptiveHeight: false, speed: 800 ...
Read more >
TypeError: element.attr is not a function Jasmine
I am using Jasmine and JQuery. I have a simple function like this below which sets attributes to a given element ...
Read more >
.prop() | jQuery API Documentation
The .prop() method gets the property value for only the first element in the matched set. It returns undefined for the value of...
Read more >
uncaught typeerror: cannot read properties of null ... - You.com
getElementById will return null if the element is not found in the DOM. null does not have a style property. You can fix...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found