mirror of
https://github.com/google/blockly.git
synced 2026-01-07 17:10:11 +01:00
fix: Deep copy options used by dropdown fields (#6425)
This uncovered a broken test that was only passing because of a side effect of the dropdown option data getting modified.
This commit is contained in:
@@ -125,6 +125,8 @@ export class FieldDropdown extends Field {
|
||||
|
||||
if (Array.isArray(menuGenerator)) {
|
||||
validateOptions(menuGenerator);
|
||||
// Deep copy the option structure so it doesn't change.
|
||||
menuGenerator = JSON.parse(JSON.stringify(menuGenerator));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -275,7 +275,7 @@ suite('JSON Block Definitions', function() {
|
||||
|
||||
const image1 = options[1][0];
|
||||
assertImageEquals(IMAGE1, image1);
|
||||
chai.assert.equal(IMAGE1.alt, IMAGE1_ALT_TEXT); // Via Msg reference
|
||||
chai.assert.equal(image1.alt, IMAGE1_ALT_TEXT); // Via Msg reference
|
||||
chai.assert.equal(VALUE1, options[1][1]);
|
||||
|
||||
const image2 = options[2][0];
|
||||
|
||||
Reference in New Issue
Block a user