Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot read property 'removeAttribute' of null: Cant find source of it

Tags:

javascript

Im getting errors over and over again on each of my sites:

VM42958:5 Uncaught TypeError: Cannot read property 'removeAttribute' of null
(anonymous function) @ VM42958:5
(anonymous function) @ VM42958:20

Unfortunately i cant find the source of this error. If i open the related JavaScript lines i find the following:

VM42958

(function()
{
  var style = document.getElementById("9mr7n8lmeyjxk84i17g5ws714i") ||
              document.documentElement.shadowRoot.getElementById("9mr7n8lmeyjxk84i17g5ws714i");
  style.removeAttribute("id");
  Object.defineProperty(style, "disabled", {value: false, enumerable: true});
  Object.defineProperty(style.sheet, "disabled", {value: false, enumerable: true});
  var deleteRule = CSSStyleSheet.prototype.deleteRule;
  CSSStyleSheet.prototype.deleteRule = function(index)
  {
    if (this != style.sheet)
      deleteRule.call(this, index);
  }
  var removeRule = CSSStyleSheet.prototype.removeRule;
  CSSStyleSheet.prototype.removeRule = function(index)
  {
    if (this != style.sheet)
      removeRule.call(this, index);
  }
})();

This is not my code and i have no idea where it is comming from or where it is used. As libraries im using bootstrap, jQuery and Chart.js.

Does somebody know this part of code or is there a way to find the source of this error. i mean directly the line where it is appearing?

The same error occurs in this jsFiddle for example: jsFiddle

like image 852
Mulgard Avatar asked Jul 01 '16 11:07

Mulgard


People also ask

What does it mean when it says Cannot read properties of null?

The "Cannot read property 'click' of null" error occurs when trying to call the click method on a null value. To solve the error, run the JS script after the DOM elements are available and make sure you only call the method on valid DOM elements.

Can you read property of null?

The "Cannot read property 'value' of null" error occurs when: trying to access the value property on a null value, e.g. after calling getElementById with an invalid identifier. inserting the JS script tag before the DOM elements have been declared.

Can not read property 0 of null?

The "Cannot read property '0' of null" error occurs when trying to access the 0th index on a variable that stores a null value. Before you access the index, make sure that the value allows for index access, e.g. is of type array or string.

Can not read property find of undefined?

The "Cannot read property 'find' of undefined" error occurs when the find() method is called on an undefined value. To solve the error, make sure to only call the find method on arrays. Here's an example of how the error occurs.


2 Answers

Same problem here. For some reason Chrome ADBlock (not plus) was the cause.

like image 179
Lebannehn Avatar answered Sep 20 '22 16:09

Lebannehn


The var style = ... statement gives null. You do not have in the document any of the queried elements.

like image 24
hsz Avatar answered Sep 20 '22 16:09

hsz