kopia lustrzana https://github.com/backface/turtlestitch
simplified and optimized Node>>parentThatIsA / parentThatIsAnyOf
rodzic
d3a01ea1ee
commit
22e12c834a
|
@ -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
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Snap! Build Your Own Blocks 5 - Beta -</title>
|
||||
<link rel="shortcut icon" href="src/favicon.ico">
|
||||
<script type="text/javascript" src="src/morphic.js?version=2019-01-10"></script>
|
||||
<script type="text/javascript" src="src/morphic.js?version=2019-02-07"></script>
|
||||
<script type="text/javascript" src="src/widgets.js?version=2018-10-02"></script>
|
||||
<script type="text/javascript" src="src/blocks.js?version=2019-02-06"></script>
|
||||
<script type="text/javascript" src="src/threads.js?version=2019-01-28"></script>
|
||||
|
|
|
@ -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 //////////////////////////////////////////////////////////////
|
||||
|
|
Ładowanie…
Reference in New Issue