Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8903977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:00:34+00:00 2026-06-15T02:00:34+00:00

In short, a script using the Dojo framework ends up with different results on

  • 0

In short, a script using the Dojo framework ends up with different results on IE.

Here is a sample page demonstrating the issue:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.3/dojo/dojo.js"></script>
<script type="text/javascript">

dojo.connect(document.body, "onload", function () {

    var d = dojo.query("div");
    var s = dojo.query("span");
    dojo.empty(d[0]);
    dojo.create("span", {innerHTML: s[0].innerHTML}, d[0]);

});

</script>
</head>
<body>
<div><span>foobar</span></div>
</body>
</html>

Don’t bother trying it over at jsFiddle, this particular case does not reproduce over there.

Sample should output foobar but on IE it does not.

Why does this happen and is there a way around it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:00:37+00:00Added an answer on June 15, 2026 at 2:00 am

    After some digging and debugging I managed to track the issue down to the internals of Dojo:

    397.empty = has("ie") ? function(node) {
        node = dom.byId(node);
        for (var c; c = node.lastChild; ) {
            _397.destroy(c);
        }
    } : function(node) {
        dom.byId(node).innerHTML = "";
    };
    
    _397.destroy = function destroy(node) {
        node = dom.byId(node);
        try {
            var doc = node.ownerDocument;
            if (!_3a2 || _3a3 != doc) {
                _3a2 = doc.createElement("div");
                _3a3 = doc;
            }
            _3a2.appendChild(node.parentNode ? node.parentNode.removeChild(node) : node);
            _3a2.innerHTML = "";
        } catch (e) {
        }
    };
    

    As can be seen from above code, IE gets a special case but unfortunately it is not functionally equivalent – things end up different.

    Not sure if this is a bug but certainly a feature of questionable merit. A workaround is to run dojo.clone() on innerHTML before invoking dojo.empty():

    var d = dojo.query("div");
    var s = dojo.query("span");
    var i = dojo.clone(s[0].innerHTML);
    dojo.empty(d[0]);
    dojo.create("span", {innerHTML: i}, d[0]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm using google gadget to write a short script and try to insert to
I'm using a short bash script to help me test an implementation of linked
I need html - java script / jquery charts using single file. What do
I'm trying to follow the basic cometd example here: http://dojotoolkit.org/reference-guide/1.7/dojox/cometd.html It's using the old
I am using a short script to post from data to a PHP processing
I've written the following short python script to download flv videos using cclive on
I'm using two short UNIX commands in my python script to get some data
I know I'm missing something here. I've been staring at this short script for
I am facing difficulty understanding references in perl. Here is a short perl script
Short story I've got a PHP script filtering incoming mail using a .qmail file.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.