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.

"TypeError: a is null" thrown only in FireFox

See original GitHub issue

I get “TypeError: a is null” thrown only in FireFox.

It show this bit as causing the error:

...1?"&nbsp;":"<br>",G=function(a){return g(a)?a.nodeValue.length:a.childNodes.leng... ----------------------------------------------------------^

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:3
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
lesilentcommented, Feb 17, 2016

I’m also getting this error, and it only occurs in Firefox. The page I’m working on is rather complicated, so I’m unable to isolate a test case. However, using the un-minified version, I was able to track down the error. The exact error message is actually “TypeError: node is null” and here’s the stack trace for version 0.8.1:

dom</nodeLength() - summernote.js:634 dom</isRightEdgeOf() - summernote.js:907 dom</isRightEdgePointOf() - summernote.js:933 range</WrappedRange/this.normalize/getVisiblePoint() - summernote.js:2472 range</WrappedRange/this.normalize() - summernote.js:2487 Editor/this.currentStyle() - summernote.js:3878 Context/this.invoke() - summernote.js:1711 Buttons/this.updateCurrentStyle() - summernote.js:5622 Context/this.invoke() - summernote.js:1711 Toolbar/this.initialize() - summernote.js:5757 Context/this.initializeModule() - summernote.js:1640 Context/this._initialize/<() - summernote.js:1570 forEach() - self-hosted:216 Context/this._initialize() - summernote.js:1569 Context/this.initialize() - summernote.js:1527 Context() - summernote.js:1715 .summernote/<() - summernote.js:1738

I did some digging and in the getVisiblePoint() function call, for some reason the block variable is null:

// point on block's edge
var block = dom.ancestor(point.node, dom.isBlock);

Later on, when the isRightEdgeOf() function is called, it traverses up the dom tree. But, when it reaches the top, node.parentNode is null and nodeLength(node.parentNode) throws the error message (because null has no childNodes). My (probably incorrect) work around was to simply add the following line to the nodeLength() function:

if (node === null) { return 0; }

1reaction
christiandevcommented, Mar 19, 2016

Thanks @lesilent

I had the same problem in firefox and corrects the problem by following your tip follows the amendment

    var nodeLength = function (node) {
      if (node === null) {
        return 0;
      } else {
        if (isText(node)) {
          return node.nodeValue.length;
        }
        return node.childNodes.length;
      }
    };

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: a is null - Firefox - Stack Overflow
this is working in Chrome, but not in FireFox, I am getting: TypeError: a is null. enter image description here. what am I...
Read more >
How to Fix TypeError: Null is Not an Object in JavaScript
The JavaScript error TypeError: null is not an object occurs when a property is accessed or a method is called on a null...
Read more >
What is error this.container is null -- I keep getting this error ...
Following a Firefox recommendation, I cleared history and cashe and other steps in their recommendation. Since then, not only my Google Calendar ...
Read more >
[Fixed in v3.2.1] Issue with CSSPlugin in Firefox: TypeError
... but CSSPlugin is throwing a TypeError in Firefox only (Both in ... v3.2.1] Issue with CSSPlugin in Firefox: TypeError: oldParent is null....
Read more >
993451 – Safari Browser Only: Globally uncaught Exception
JavaScriptException:(TypeError): 'null' is not an object (evaluating 'this.form. ... Safari still throws the Globally uncaught exception, ...
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