diff --git a/HISTORY.md b/HISTORY.md
index cb4353a6..eacc1c69 100755
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -42,6 +42,7 @@
* Store: tweaked loading mechanism to enable command blocks inside reporter rings
* Objects: tweaked spec for settings getter
* Blocks: improved dropping command blocks into reporter rings
+* Morphic: simplified and optimized Node>>parentThatIsA / parentThatIsAnyOf
### 2019-02-06
* Blocks, BYOB: refactored custom block input options and drop-down menus
diff --git a/snap.html b/snap.html
index 67e670b8..22dd7751 100755
--- a/snap.html
+++ b/snap.html
@@ -4,7 +4,7 @@
Snap! Build Your Own Blocks 5 - Beta -
-
+
diff --git a/src/morphic.js b/src/morphic.js
index c8687d29..1eb328d9 100644
--- a/src/morphic.js
+++ b/src/morphic.js
@@ -1162,7 +1162,7 @@
/*global window, HTMLCanvasElement, FileReader, Audio, FileList, Map*/
-var morphicVersion = '2019-January-10';
+var morphicVersion = '2019-February-07';
var modules = {}; // keep track of additional loaded modules
var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug
@@ -2845,34 +2845,24 @@ Node.prototype.siblings = function () {
});
};
-Node.prototype.parentThatIsA = function (constructor) {
+Node.prototype.parentThatIsA = function () {
// including myself
- if (this instanceof constructor) {
- return this;
+ // Note: you can pass in multiple constructors to test for
+ var i;
+ for (i = 0; i < arguments.length; i += 1) {
+ if (this instanceof arguments[i]) {
+ return this;
+ }
}
if (!this.parent) {
return null;
}
- return this.parent.parentThatIsA(constructor);
+ return this.parentThatIsA.apply(this.parent, arguments);
};
Node.prototype.parentThatIsAnyOf = function (constructors) {
- // including myself
- var yup = false,
- myself = this;
- constructors.forEach(function (each) {
- if (myself.constructor === each) {
- yup = true;
- return;
- }
- });
- if (yup) {
- return this;
- }
- if (!this.parent) {
- return null;
- }
- return this.parent.parentThatIsAnyOf(constructors);
+ // deprecated, use parentThatIsA instead
+ return this.parentThatIsA.apply(this, constructors);
};
// Morphs //////////////////////////////////////////////////////////////