clarkyblade / blockly

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

options readOnly breaks blockly #113

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When option "readOnly" is active.
Nothing will be displayed and on mouse over i get:

TypeError: Blockly.mainWorkspace is null
/js/blockly/blockly_compressed.js
Line 848

Version: r617

Demo:

    Blockly.inject(
        document.getElementById('blocklyDiv' + options.item), 
        {
          path: '/js/blockly/',
          readOnly = true,
          trashcan = false
        }
    );

    var xml = 
    '<xml>' +
    '  <block type="math_number"><title name="NUM">16</title></block>' +
    '</xml>';

    Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, xml);

Original issue reported on code.google.com by henn...@mst.ch on 6 Feb 2013 at 12:27

GoogleCodeExporter commented 9 years ago
Attached a working demo script.

Original comment by henn...@mst.ch on 6 Feb 2013 at 1:20

Attachments:

GoogleCodeExporter commented 9 years ago
FieldDropdown looks like it should be an object, but has several class members 
that are initialized upon initialization of an object, but no guarantee that 
the object is a singleton.

I don't see this issue in version r626, but I see use of this svgGroup_ class 
member:

/**
 * Hide the dropdown menu.
 */
Blockly.FieldDropdown.hide = function() {
  Blockly.FieldDropdown.svgGroup_.style.display = 'none';
***Uncaught TypeError: Cannot read property 'style' of undefined
***Uncaught TypeError: Cannot read property 'style' of undefined
  Blockly.FieldDropdown.openDropdown_ = null;
};

Original comment by s...@chromium.org on 9 Feb 2013 at 6:50

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

Original comment by s...@google.com on 9 Feb 2013 at 7:38

GoogleCodeExporter commented 9 years ago
Revision: 628
Author:   scr@google.com
Date:     Fri Feb  8 23:36:25 2013
Log:      Fix misuse of Blockly.FieldDropdown.svgGroup_ without null check.

Also, while in there, used css to change the display mode rather than
setting the style directly.

BUG=113
TBR=neil.fraser@gmail.com

Review URL: https://codereview.appspot.com/7304066
http://code.google.com/p/blockly/source/detail?r=628

Modified:
 /trunk/blockly_compressed.js
 /trunk/blockly_core_deps.js
 /trunk/core/blockly.gss
 /trunk/core/blockly_renaming_map.js
 /trunk/core/field_dropdown.js
 /trunk/core/inject.js
 /trunk/media/blockly.css

Original comment by s...@google.com on 9 Feb 2013 at 8:15