Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE10 d3.v3.js error: Unable to get property 'prototype' of undefined or null reference

Tags:

My page is loading perfectly in IE9, Safari, Chrome & Firefox.

But when it coems to IE10 , it throws error : Unable to get property 'prototype' of undefined or null reference in d3.v3.js at line : d3_window.CSSStyleDeclaration.prototype.

 try {
    d3_document.createElement("div").style.setProperty("opacity", 0, "");
  } catch (error) {
    var d3_style_prototype = d3_window.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;
    d3_style_prototype.setProperty = function(name, value, priority) {
      d3_style_setProperty.call(this, name, value + "", priority);
    };
  }

I am not getting what exactly is being done here.

In try block even though setProperty method we can see in debugger on d3_document.createElement("div").style it is throwing error as : Object doesn't support property or method 'setProperty'

In catch block it tries to access prototype of window's CSSStyleDeclaration , but that is undefined.

Anybody occured with same problem while using d3.v3.js

like image 963
vajrakumar Avatar asked Mar 04 '13 07:03

vajrakumar


1 Answers

This can be fixed with a DOCTYPE:

<!DOCTYPE html>

And a meta tag:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

Without those, IE will go into quirks mode and not understand what CSSStyleDeclaration is.

like image 200
Langdon Avatar answered Sep 27 '22 20:09

Langdon