diff --git a/blockly_compressed.js b/blockly_compressed.js index 503b3e8ce..387bfe63a 100644 --- a/blockly_compressed.js +++ b/blockly_compressed.js @@ -1301,8 +1301,9 @@ Blockly.Field.prototype.forceRerender=function(){this.isDirty_=!0;this.sourceBlo Blockly.Field.prototype.setValue=function(a){if(null!==a){var b=this.doClassValidation_(a);a=this.processValidation_(a,b);if(!(a instanceof Error)){if(b=this.getValidator())if(b=b.call(this,a),a=this.processValidation_(a,b),a instanceof Error)return;b=this.getValue();b!==a&&(this.sourceBlock_&&Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.BlockChange(this.sourceBlock_,"field",this.name,b,a)),this.doValueUpdate_(a),this.isDirty_&&this.forceRerender())}}}; Blockly.Field.prototype.processValidation_=function(a,b){if(null===b)return this.doValueInvalid_(a),this.isDirty_&&this.forceRerender(),Error();void 0!==b&&(a=b);return a};Blockly.Field.prototype.getValue=function(){return this.value_};Blockly.Field.prototype.doClassValidation_=function(a){return a=this.classValidator(a)};Blockly.Field.prototype.doValueUpdate_=function(a){this.value_=a;this.isDirty_=!0;this.text_=String(a)};Blockly.Field.prototype.doValueInvalid_=function(a){}; Blockly.Field.prototype.onMouseDown_=function(a){this.sourceBlock_&&this.sourceBlock_.workspace&&(a=this.sourceBlock_.workspace.getGesture(a))&&a.setStartField(this)};Blockly.Field.prototype.setTooltip=function(a){var b=this.getClickTarget_();b?b.tooltip=a||""===a?a:this.sourceBlock_:this.tooltip_=a};Blockly.Field.prototype.getClickTarget_=function(){return this.clickTarget_||this.getSvgRoot()};Blockly.Field.prototype.getAbsoluteXY_=function(){return Blockly.utils.style.getPageOffset(this.borderRect_)}; -Blockly.Field.prototype.referencesVariables=function(){return!1};Blockly.Field.prototype.getParentInput=function(){for(var a=null,b=this.sourceBlock_,c=b.inputList,d=0;da||a>this.fieldRow.length)throw Error("index "+a+" out of bounds.");if(!b&&!c)return a;"string"==typeof b&&(b=new Blockly.FieldLabel(b));b.setSourceBlock(this.sourceBlock_);this.sourceBlock_.rendered&&b.init();b.name=c;b.prefixField&&(a=this.insertFieldAt(a,b.prefixField));this.fieldRow.splice(a,0,b);++a;b.suffixField&&(a=this.insertFieldAt(a,b.suffixField));this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours_()); return a};Blockly.Input.prototype.removeField=function(a){for(var b=0,c;c=this.fieldRow[b];b++)if(c.name===a){c.dispose();this.fieldRow.splice(b,1);this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours_());return}throw Error('Field "%s" not found.',a);};Blockly.Input.prototype.isVisible=function(){return this.visible_}; diff --git a/core/field_registry.js b/core/field_registry.js index 2125ea97f..114b89f9f 100644 --- a/core/field_registry.js +++ b/core/field_registry.js @@ -57,6 +57,7 @@ Blockly.fieldRegistry.register = function(type, fieldClass) { if (!fieldClass || (typeof fieldClass.fromJson != 'function')) { throw Error('Field "' + fieldClass + '" must have a fromJson function'); } + type = type.toLowerCase(); Blockly.fieldRegistry.typeMap_[type] = fieldClass; }; @@ -71,7 +72,8 @@ Blockly.fieldRegistry.register = function(type, fieldClass) { * @package */ Blockly.fieldRegistry.fromJson = function(options) { - var fieldClass = Blockly.fieldRegistry.typeMap_[options['type']]; + var type = options['type'].toLowerCase(); + var fieldClass = Blockly.fieldRegistry.typeMap_[type]; if (!fieldClass) { console.warn('Blockly could not create a field of type ' + options['type'] + '. The field is probably not being registered. This could be because' + diff --git a/tests/mocha/field_registry_test.js b/tests/mocha/field_registry_test.js index 1fa06bc9d..c04d135f4 100644 --- a/tests/mocha/field_registry_test.js +++ b/tests/mocha/field_registry_test.js @@ -110,8 +110,7 @@ suite('Field Registry', function() { chai.assert.isTrue(spy.called); spy.restore(); }); - // TODO: Is this supposed to be case sensitive? - test.skip('Case Different', function() { + test('Case Different', function() { Blockly.fieldRegistry.register('field_custom_test', CustomFieldType); var json = {