mirror of
https://github.com/google/blockly.git
synced 2026-01-12 03:17:09 +01:00
* fix: JSON deserialization fails (bug #6091) (collapsed procedure call blocks) * fix: JSON deserialization fails (bug #6091) changed fix, added tests (collapsed procedure call blocks)
This commit is contained in:
committed by
Beka Westberg
parent
4de439b64e
commit
a3a9dcf366
@@ -711,10 +711,10 @@ const PROCEDURE_CALL_COMMON = {
|
||||
if (!mutatorOpen) {
|
||||
this.quarkConnections_ = {};
|
||||
this.quarkIds_ = null;
|
||||
}
|
||||
if (!paramIds) {
|
||||
// Reset the quarks (a mutator is about to open).
|
||||
return;
|
||||
} else {
|
||||
// fix #6091 - this call could cause an error when outside if-else
|
||||
// expanding block while mutating prevents another error (ancient fix)
|
||||
this.setCollapsed(false);
|
||||
}
|
||||
// Test arguments (arrays of strings) for changes. '\n' is not a valid
|
||||
// argument name character, so it is a valid delimiter here.
|
||||
@@ -726,7 +726,6 @@ const PROCEDURE_CALL_COMMON = {
|
||||
if (paramIds.length !== paramNames.length) {
|
||||
throw RangeError('paramNames and paramIds must be the same length.');
|
||||
}
|
||||
this.setCollapsed(false);
|
||||
if (!this.quarkIds_) {
|
||||
// Initialize tracking for this block.
|
||||
this.quarkConnections_ = {};
|
||||
|
||||
@@ -611,8 +611,8 @@ const initBlock = function(block, rendered) {
|
||||
// operation to decrease load time.
|
||||
block.setConnectionTracking(false);
|
||||
|
||||
blockSvg.initSvg();
|
||||
blockSvg.render(false);
|
||||
block.initSvg();
|
||||
block.render(false);
|
||||
// fixes #6076 JSO deserialization doesn't
|
||||
// set .iconXY_ property so here it will be set
|
||||
const icons = block.getIcons();
|
||||
|
||||
@@ -1672,12 +1672,52 @@ Serializer.Mutations.Procedure.Caller = new SerializerTestCase(
|
||||
'</mutation>' +
|
||||
'</block>' +
|
||||
'</xml>');
|
||||
Serializer.Mutations.Procedure.CollapsedProceduresCallreturn = new SerializerTestCase(
|
||||
'CollapsedProceduresCallreturn',
|
||||
'<xml xmlns="https://developers.google.com/blockly/xml">' +
|
||||
'<variables>' +
|
||||
'<variable id="aaaaaaaaaaaaaaaaaaaa">x</variable>' +
|
||||
'</variables>' +
|
||||
'<block type="procedures_defreturn" id="id******************" x="42" y="42">' +
|
||||
'<mutation>' +
|
||||
'<arg name="x" varid="aaaaaaaaaaaaaaaaaaaa"></arg>' +
|
||||
'</mutation>' +
|
||||
'<field name="NAME">do something</field>' +
|
||||
'<comment pinned="false" h="80" w="160">Describe this function...</comment>' +
|
||||
'</block>' +
|
||||
'<block type="procedures_callreturn" id="id1*****************" collapsed="true" x="52" y="52">' +
|
||||
'<mutation name="do something">' +
|
||||
'<arg name="x"></arg>' +
|
||||
'</mutation>' +
|
||||
'</block>' +
|
||||
'</xml>');
|
||||
Serializer.Mutations.Procedure.CollapsedProceduresCallnoreturn = new SerializerTestCase(
|
||||
'CollapsedProceduresCallnoreturn',
|
||||
'<xml xmlns="https://developers.google.com/blockly/xml">' +
|
||||
'<variables>' +
|
||||
'<variable id="aaaaaaaaaaaaaaaaaaaa">x</variable>' +
|
||||
'</variables>' +
|
||||
'<block type="procedures_defnoreturn" id="id******************" x="42" y="42">' +
|
||||
'<mutation>' +
|
||||
'<arg name="x" varid="aaaaaaaaaaaaaaaaaaaa"></arg>' +
|
||||
'</mutation>' +
|
||||
'<field name="NAME">do something</field>' +
|
||||
'<comment pinned="false" h="80" w="160">Describe this function...</comment>' +
|
||||
'</block>' +
|
||||
'<block type="procedures_callnoreturn" id="id1*****************" collapsed="true" x="52" y="52">' +
|
||||
'<mutation name="do something">' +
|
||||
'<arg name="x"></arg>' +
|
||||
'</mutation>' +
|
||||
'</block>' +
|
||||
'</xml>');
|
||||
Serializer.Mutations.Procedure.testCases = [
|
||||
Serializer.Mutations.Procedure.NoMutation,
|
||||
Serializer.Mutations.Procedure.Variables,
|
||||
Serializer.Mutations.Procedure.NoStatements,
|
||||
Serializer.Mutations.Procedure.IfReturn,
|
||||
Serializer.Mutations.Procedure.Caller,
|
||||
Serializer.Mutations.Procedure.CollapsedProceduresCallreturn,
|
||||
Serializer.Mutations.Procedure.CollapsedProceduresCallnoreturn,
|
||||
];
|
||||
|
||||
Serializer.Mutations.Procedure.Names = new SerializerTestSuite('Names');
|
||||
|
||||
Reference in New Issue
Block a user