From affbe2f4371546e9f19c552396fe845ba1297e1e Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 7 Feb 2019 09:54:22 +0100 Subject: [PATCH] refactored for optimized parent-by-type detection --- HISTORY.md | 1 + snap.html | 6 +++--- src/blocks.js | 8 +++++--- src/lists.js | 6 +++--- src/tables.js | 6 +++--- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index eacc1c69..108ce403 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -43,6 +43,7 @@ * Objects: tweaked spec for settings getter * Blocks: improved dropping command blocks into reporter rings * Morphic: simplified and optimized Node>>parentThatIsA / parentThatIsAnyOf +* Blocks, Lists, Tables: refactored for optimized parent-by-type detection ### 2019-02-06 * Blocks, BYOB: refactored custom block input options and drop-down menus diff --git a/snap.html b/snap.html index 22dd7751..7fee31d2 100755 --- a/snap.html +++ b/snap.html @@ -6,14 +6,14 @@ - + - + - + diff --git a/src/blocks.js b/src/blocks.js index 2fb18a92..02adab70 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -148,7 +148,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2019-February-06'; +modules.blocks = '2019-February-07'; var SyntaxElementMorph; var BlockMorph; @@ -1966,8 +1966,10 @@ SyntaxElementMorph.prototype.fixLayout = function (silently) { } } if (this.width() !== initialExtent.x) { - affected = this.parentThatIsAnyOf( - [ReporterBlockMorph, CommandSlotMorph, RingCommandSlotMorph] + affected = this.parentThatIsA( + ReporterBlockMorph, + CommandSlotMorph, + RingCommandSlotMorph ); if (affected) { affected.fixLayout(); diff --git a/src/lists.js b/src/lists.js index ad207dd3..5af8170b 100644 --- a/src/lists.js +++ b/src/lists.js @@ -62,7 +62,7 @@ CellMorph, ArrowMorph, MenuMorph, snapEquals, Morph, isNil, localize, isString, MorphicPreferences, TableDialogMorph, SpriteBubbleMorph, SpeechBubbleMorph, TableFrameMorph, TableMorph, Variable, isSnapObject*/ -modules.lists = '2019-January-10'; +modules.lists = '2019-February-07'; var List; var ListWatcherMorph; @@ -924,11 +924,11 @@ ListWatcherMorph.prototype.userMenu = function () { }; ListWatcherMorph.prototype.showTableView = function () { - var view = this.parentThatIsAnyOf([ + var view = this.parentThatIsA( SpriteBubbleMorph, SpeechBubbleMorph, CellMorph - ]); + ); if (!view) {return; } if (view instanceof SpriteBubbleMorph) { view.changed(); diff --git a/src/tables.js b/src/tables.js index 69c3d8fc..ce88155f 100644 --- a/src/tables.js +++ b/src/tables.js @@ -70,7 +70,7 @@ SpriteMorph, Context, Costume, ArgMorph, BlockEditorMorph, SymbolMorph, SyntaxElementMorph, MenuMorph, SpriteBubbleMorph, SpeechBubbleMorph, Sound, CellMorph, ListWatcherMorph, isNil, BoxMorph, Variable, isSnapObject*/ -modules.tables = '2017-September-01'; +modules.tables = '2019-February-07'; var Table; var TableCellMorph; @@ -1059,11 +1059,11 @@ TableMorph.prototype.openInDialog = function () { }; TableMorph.prototype.showListView = function () { - var view = this.parentThatIsAnyOf([ + var view = this.parentThatIsA( SpriteBubbleMorph, SpeechBubbleMorph, CellMorph - ]); + ); if (!view) {return; } if (view instanceof SpriteBubbleMorph) { view.changed();