FLUID-3679: JavaScript error "'script.parentNode' is null or not an object" on IE when running multiple instances of fluid (swfobject.js)

Metadata

Source
FLUID-3679
Type
Bug
Priority
Major
Status
Closed
Resolution
Fixed
Assignee
N/A
Reporter
Andrew Wills
Created
2010-07-30T17:55:53.326-0400
Updated
2010-09-08T13:42:56.310-0400
Versions
  1. 1.1
  2. 1.1.1
  3. 1.1.2
  4. 1.2beta1
  5. 1.2
Fixed Versions
  1. 1.1.3
  2. 1.2.1
  3. 1.3
Component
  1. Framework

Description

The swfobject.js dependency, included with Fluid Infusion, causes A JavaScript error on IE browsers when you run more than 1 copy of fluid on a page. (Note: this is something we do commonly in uPortal – each portlet loads & uses its own copy.)

The error is caused when JS attempts to call 'script.parentNode.removeChild(script)' on the same element more than once.

Eyeballing the code, it looks as though this issue is fixed in swfobject 2.2: http://code.google.com/p/swfobject/downloads/detail?name=swfobject_2_2.zip

Would it be possible to bump the embedded version of swfobject to 2.2?

          • OFFENDING CODE *****
            /* Cross-browser onDomLoad
  • Based on Dean Edwards' solution: http://dean.edwards.name/weblog/2006/06/again/
  • Will fire an event as soon as the DOM of a page is loaded (supported by Gecko based browsers - like Firefox -, IE, Opera9+, Safari)
    */
    var onDomLoad = function() {
    if (!ua.w3cdom) {
    return;
    }
    addDomLoadEvent(main);
    if (ua.ie && ua.win) {
    try { // Avoid a possible Operation Aborted error
    doc.write("<scr" + "ipt id=__ie_ondomload defer=true src=//:></scr" + "ipt>"); // String is split into pieces to avoid Norton AV to add code that can cause errors
    script = getElementById("__ie_ondomload");
    if (script) {
    addListener(script, "onreadystatechange", checkReadyState);
    }
    }
    catch(e) {}
    }
    if (ua.webkit && typeof doc.readyState != UNDEF) {
    timer = setInterval(function() { if (/loaded|complete/.test(doc.readyState)) { callDomLoadFunctions(); }}, 10);
    }
    if (typeof doc.addEventListener != UNDEF) {
    doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, null);
    }
    addLoadEvent(callDomLoadFunctions);
    }();

function checkReadyState() {

if (script.readyState == "complete") {
script.parentNode.removeChild(script);
callDomLoadFunctions();
}
}
*****

Environments

IE browser, all versions (afaik)

Comments

  • Harris Wong commented 2010-08-24T14:25:46.433-0400

    Replaced SWFObject v2.1 to SWFObject v2.2. Changed the version number on the readme file and the swfobject-LICENSE file.

  • Mike Lam commented 2010-09-08T13:42:56.266-0400

    Committed and available to trunk, 1.1.3, 1.2.1, and 1.3.