Fix JS and PHP list/text blocks.

The length and is_empty blocks can take either text or lists.
This commit is contained in:
Neil Fraser
2015-10-03 07:45:16 -07:00
parent ac9de0d915
commit c413fa1678
10 changed files with 43 additions and 23 deletions

View File

@@ -66,14 +66,14 @@ Blockly.JavaScript['lists_repeat'] = function(block) {
};
Blockly.JavaScript['lists_length'] = function(block) {
// List length.
// String or array length.
var argument0 = Blockly.JavaScript.valueToCode(block, 'VALUE',
Blockly.JavaScript.ORDER_FUNCTION_CALL) || '[]';
return [argument0 + '.length', Blockly.JavaScript.ORDER_MEMBER];
};
Blockly.JavaScript['lists_isEmpty'] = function(block) {
// Is the list empty?
// Is the string null or array empty?
var argument0 = Blockly.JavaScript.valueToCode(block, 'VALUE',
Blockly.JavaScript.ORDER_MEMBER) || '[]';
return ['!' + argument0 + '.length', Blockly.JavaScript.ORDER_LOGICAL_NOT];