From 4b92a387a9328a9072e9f48877c03ee9b714f81c Mon Sep 17 00:00:00 2001 From: samreid Date: Mon, 17 Aug 2020 18:14:09 -0600 Subject: [PATCH] Improve state scope check, see https://github.com/phetsims/tandem/issues/193 --- js/Tandem.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/Tandem.js b/js/Tandem.js index 0206b8a6..d22dabb4 100644 --- a/js/Tandem.js +++ b/js/Tandem.js @@ -164,6 +164,16 @@ class Tandem { } } + /** + * Returns true if this Tandem has the specified ancestor Tandem. + * @param ancestor + * @returns {boolean} + * @public + */ + hasAncestor( ancestor ) { + return this.parentTandem === ancestor || ( this.parentTandem && this.parentTandem.hasAncestor( ancestor ) ); + } + /** * Removes a PhetioObject and signifies to listeners that it has been removed. * @param {PhetioObject} phetioObject