mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Added handling of dynamic functions passed to opt_config.
This commit is contained in:
@@ -58,7 +58,11 @@ Blockly.Field = function(value, opt_validator, opt_config) {
|
||||
this.size_ = new Blockly.utils.Size(0, 0);
|
||||
|
||||
if (opt_config) {
|
||||
var tooltip = Blockly.utils.replaceMessageReferences(opt_config['tooltip']);
|
||||
var tooltip = opt_config['tooltip'];
|
||||
if (typeof tooltip == 'string') {
|
||||
tooltip = Blockly.utils.replaceMessageReferences(
|
||||
opt_config['tooltip']);
|
||||
}
|
||||
tooltip && this.setTooltip(tooltip);
|
||||
|
||||
// TODO: Possibly eventually add configurations like cursor and css class.
|
||||
|
||||
@@ -359,6 +359,15 @@ suite('Abstract Fields', function() {
|
||||
});
|
||||
chai.assert.equal(field.tooltip_, 'test tooltip');
|
||||
});
|
||||
test('JS Constructor - Dynamic', function() {
|
||||
var returnTooltip = function() {
|
||||
return 'dynamic tooltip text';
|
||||
};
|
||||
var field = new Blockly.Field('value', null, {
|
||||
tooltip: returnTooltip
|
||||
});
|
||||
chai.assert.equal(field.tooltip_, returnTooltip);
|
||||
});
|
||||
test('JSON Definition', function() {
|
||||
var field = CustomField.fromJson({
|
||||
tooltip: "test tooltip"
|
||||
|
||||
Reference in New Issue
Block a user