mirror of
https://github.com/google/blockly.git
synced 2026-01-09 10:00:09 +01:00
Create null objects properly.
new Object(null) doesn’t do anything, that’s just broken. And the for loop with keys is silly.
This commit is contained in:
@@ -34,4 +34,4 @@ goog.provide('Blockly.Blocks');
|
||||
* A mapping of block type names to block prototype objects.
|
||||
* @type {!Object.<string,Object>}
|
||||
*/
|
||||
Blockly.Blocks = new Object(null);
|
||||
Blockly.Blocks = Object.create(null);
|
||||
|
||||
@@ -48,7 +48,7 @@ Blockly.VariableMap = function(workspace) {
|
||||
* @type {!Object.<string, !Array.<Blockly.VariableModel>>}
|
||||
* @private
|
||||
*/
|
||||
this.variableMap_ = {};
|
||||
this.variableMap_ = Object.create(null);
|
||||
|
||||
/**
|
||||
* The workspace this map belongs to.
|
||||
@@ -61,7 +61,7 @@ Blockly.VariableMap = function(workspace) {
|
||||
* Clear the variable map.
|
||||
*/
|
||||
Blockly.VariableMap.prototype.clear = function() {
|
||||
this.variableMap_ = new Object(null);
|
||||
this.variableMap_ = Object.create(null);
|
||||
};
|
||||
|
||||
/* Begin functions for renaming variables. */
|
||||
@@ -380,9 +380,8 @@ Blockly.VariableMap.prototype.getVariableTypes = function(ws) {
|
||||
*/
|
||||
Blockly.VariableMap.prototype.getAllVariables = function() {
|
||||
var all_variables = [];
|
||||
var keys = Object.keys(this.variableMap_);
|
||||
for (var i = 0; i < keys.length; i++ ) {
|
||||
all_variables = all_variables.concat(this.variableMap_[keys[i]]);
|
||||
for (var key in this.variableMap_) {
|
||||
all_variables = all_variables.concat(this.variableMap_[key]);
|
||||
}
|
||||
return all_variables;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user