duckfly-tw / ie7-js

A JavaScript library to make MSIE behave like a standards-compliant browser.
http://code.google.com/p/ie7-js
0 stars 0 forks source link

Error: Unable to get value of the property 'split': object is null or undefined #376

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi. Due to confidentially agreements I've signed, I cannot point you to a page 
that shows the problem, nor am I even sure how to reproduce the problem.

I suspect it may happen on all systems using:

http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE8.js

I could view the error by using IE9 with the developer tools and setting the 
mode to IE7 browser standards/IE7 document standards and then running the 
script debugger. I could also view it with IE9 set to compatibility mode.

The problem seems pretty simple: the following code tries to call split() on an 
undefined value.

// =========================================================================
// ie8-layout.js
// =========================================================================

if (appVersion < 8) {
  IE7.CSS.addRecalc("border-spacing", NUMERIC, function(element) {
    if (element.currentStyle.borderCollapse !== "collapse") {
    element.cellSpacing = getPixelValue(element, element.currentStyle["ie7-border-spacing"].split(" ")[0]);
    }
  });

This looks like a reasonable fix:

// =========================================================================
// ie8-layout.js
// =========================================================================

if (appVersion < 8) {
  IE7.CSS.addRecalc("border-spacing", NUMERIC, function(element) {
    if (element.currentStyle.borderCollapse !== "collapse") {
    element.cellSpacing = getPixelValue(element, getDefinedStyle(element, 'border-spacing').split(" ")[0]);
    }
  });

I don't know if this causes a different problem, but my page now runs without 
error. In any case, it is clear that there are conditions under which 
"ie7-border-style" is not defined. The code needs to guard against this somehow.

Original issue reported on code.google.com by tfrei...@gmail.com on 30 Aug 2012 at 10:18