mirror of
https://github.com/google/blockly.git
synced 2026-01-06 08:30:13 +01:00
fix: bad JSON state leaving events disabled (#7501)
* fix: broken JSON state stopping event firing * chore: add unit test for events not breaking
This commit is contained in:
@@ -399,9 +399,13 @@ export function appendInternal(
|
||||
}
|
||||
eventUtils.disable();
|
||||
|
||||
const block = appendPrivate(state, workspace, {parentConnection, isShadow});
|
||||
let block;
|
||||
try {
|
||||
block = appendPrivate(state, workspace, {parentConnection, isShadow});
|
||||
} finally {
|
||||
eventUtils.enable();
|
||||
}
|
||||
|
||||
eventUtils.enable();
|
||||
if (eventUtils.isEnabled()) {
|
||||
eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))(block));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,25 @@ suite('JSO Deserialization', function () {
|
||||
});
|
||||
|
||||
suite('Events', function () {
|
||||
test('bad JSON does not leave events disabled', function () {
|
||||
const state = {
|
||||
'blocks': {
|
||||
'blocks': [
|
||||
{
|
||||
'type': 'undefined_block',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
chai.assert.throws(() => {
|
||||
Blockly.serialization.workspaces.load(state, this.workspace);
|
||||
});
|
||||
chai.assert.isTrue(
|
||||
Blockly.Events.isEnabled(),
|
||||
'Expected events to be enabled',
|
||||
);
|
||||
});
|
||||
|
||||
suite('Finished loading', function () {
|
||||
test('Just var', function () {
|
||||
const state = {
|
||||
|
||||
Reference in New Issue
Block a user