Unverified Commit c015c8f3 authored by Beka Westberg's avatar Beka Westberg Committed by GitHub

Fix nullptr in text connection check (#2206)

parent 1ece0851
......@@ -36,8 +36,12 @@ Blockly.Blocks['text'] = {
};
Blockly.Blocks.text.connectionCheck = function (myConnection, otherConnection, opt_value) {
var block = myConnection.sourceBlock_;
var otherTypeArray = otherConnection.check_;
if (!otherTypeArray) { // Other connection accepts everything.
return true;
}
var block = myConnection.sourceBlock_;
var shouldIgnoreError = Blockly.mainWorkspace.isLoading;
var value = opt_value || block.getFieldValue('TEXT');
......
......@@ -39,6 +39,7 @@ suite('Text Blocks', function() {
var string = { check_: ['String'] };
var key = { check_: ['Key'] };
var many = { check_: ['Number', 'String'] };
var untyped = { check_: null };
var invalidNumbers = [
'cat', '4cat', 'e', ' zero ', '0x0', '.', '-', '+', '', '-e-', '+e+'
];
......@@ -83,6 +84,14 @@ suite('Text Blocks', function() {
test('Should connect with many checks', function() {
chai.assert.isTrue(check(mockConnection('cat'), many));
})
});
test('Should connect to untyped when a number', function() {
chai.assert.isTrue(check(mockConnection('1'), untyped));
});
test('Should connect to untyped when not number', function() {
chai.assert.isTrue(check(mockConnection('cat'), untyped));
});
});
})
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment