YongJunL / blockly

Automatically exported from code.google.com/p/blockly
0 stars 0 forks source link

IE9, Convert (blocks) to XML #172

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I tried to find similiar issues like mine, but I fail to find one, so I decided 
to post new.

This works on IE10, Chrome, Safari, Firefox... without any problems, but on IE9 
this (workspaceToDom) function fails. (you can find this problem directly from 
blockly demos:code --> #1 drop block(any) #2 change tab to XML --> boom)

<pre><code class="javascript">
Blockly.Xml.workspaceToDom = function (a) {
    var b = Blockly.svgSize().width,
        c = goog.dom.createDom("xml");
    a = a.getTopBlocks(!0);
    for (var d = 0, e; e = a[d]; d++) {
        var f = Blockly.Xml.blockToDom_(e);
        e = e.getRelativeToSurfaceXY();
        f.setAttribute("x", Blockly.RTL ? b - e.x : e.x);
        f.setAttribute("y", e.y);

        c.appendChild(f) //<-- "Unexpected call to method or property access."
        // @IE9 : c.typeOf('HTMLUnknownElement')
        // @IE9 : f.typeOf('HTMLUnknownElement')
        // @!IE9: c.typeOf('XML')
        // @!IE9: f.typeOf('Block')
    }
    return c
};
</code></pre>

I have (got 2013.10.14) version of blockly. I have tried some workarounds, but 
as I'm not expert on Javascript, I'm having difficulties to understand fix 
function (so if you have a fix, please post a sample).

Original issue reported on code.google.com by fdo...@gmail.com on 18 Oct 2013 at 12:36

GoogleCodeExporter commented 9 years ago
Hello..

please, i know that is a very old issue.. but, did you resolved this problem?

Original comment by flaviole...@gmail.com on 13 Mar 2015 at 3:06

GoogleCodeExporter commented 9 years ago
Unfortunately none of the Blockly developers have access to older versions of 
IE.  We'd fix it if we could.  :(

https://plus.google.com/+NeilFraserName/posts/dmh9rjBoRUr

Original comment by neil.fra...@gmail.com on 13 Mar 2015 at 5:30

GoogleCodeExporter commented 9 years ago
i found a solution with my team.. 
we note that problem occurs in a append command in Blockly.Xml.workspaceToDom.

before:

Blockly.Xml = {};
Blockly.Xml.workspaceToDom = function(a)
{
    var b;
    Blockly.RTL && (b = a.getWidth());
    var c = goog.dom.createDom("xml");
    a = a.getTopBlocks(!0);
    for (var d = 0, e; e = a[d]; d++)
    {
        var f = Blockly.Xml.blockToDom_(e);
        e = e.getRelativeToSurfaceXY();
        f.setAttribute("x", Blockly.RTL ? b - e.x : e.x);
        f.setAttribute("y", e.y);
        c.appendChild(f)
    }
    return c
};

after:

Blockly.Xml = {};
Blockly.Xml.workspaceToDom = function(a)
{
{
    var b;
    var c = goog.dom.createDom("xml");
    var returnValue = (new XMLSerializer()).serializeToString(c);                    

    Blockly.RTL && (b = a.getWidth());
    a = a.getTopBlocks(!0);                    

    for (var d = 0, e; e = a[d]; d++)
    {
        var f = Blockly.Xml.blockToDom_(e);
        e = e.getRelativeToSurfaceXY();
        f.setAttribute("x", Blockly.RTL ? b - e.x : e.x);
        f.setAttribute("y", e.y);
        var aux = (new XMLSerializer()).serializeToString(f);
        returnValue += aux;
    }                 
    return returnValue;
};

now, we dont return xml.. now the return is a string with the xml code.

Original comment by flaviole...@gmail.com on 13 Mar 2015 at 8:05