diff --git a/packages/app/src/Application.js b/packages/app/src/Application.js index 1e2a234..892e179 100644 --- a/packages/app/src/Application.js +++ b/packages/app/src/Application.js @@ -129,7 +129,7 @@ * @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set * to true. Should it destroy the base texture of the child sprite */ - destroy(removeView) + destroy(removeView, stageOptions) { // Destroy plugins in the opposite order // which they were constructed @@ -141,7 +141,7 @@ plugin.destroy.call(this); }); - this.stage.destroy(); + this.stage.destroy(stageOptions); this.stage = null; this.renderer.destroy(removeView); diff --git a/packages/app/src/Application.js b/packages/app/src/Application.js index 1e2a234..892e179 100644 --- a/packages/app/src/Application.js +++ b/packages/app/src/Application.js @@ -129,7 +129,7 @@ * @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set * to true. Should it destroy the base texture of the child sprite */ - destroy(removeView) + destroy(removeView, stageOptions) { // Destroy plugins in the opposite order // which they were constructed @@ -141,7 +141,7 @@ plugin.destroy.call(this); }); - this.stage.destroy(); + this.stage.destroy(stageOptions); this.stage = null; this.renderer.destroy(removeView); diff --git a/packages/app/test/index.js b/packages/app/test/index.js index 1e84a1e..ff02bfe 100644 --- a/packages/app/test/index.js +++ b/packages/app/test/index.js @@ -1,6 +1,6 @@ const { Application } = require('../'); const { autoDetectRenderer } = require('@pixi/canvas-renderer'); -const { Container } = require('@pixi/display'); +const { Container, DisplayObject } = require('@pixi/display'); const { skipHello } = require('@pixi/utils'); skipHello(); @@ -56,6 +56,30 @@ expect(document.body.contains(view)).to.be.false; }); + it('should not destroy children by default', function () + { + const app = new Application(); + const stage = app.stage; + const child = new DisplayObject(); + + stage.addChild(child); + + app.destroy(true); + expect(child.transform).to.not.be.null; + }); + + it('should allow children destroy', function () + { + const app = new Application(); + const stage = app.stage; + const child = new DisplayObject(); + + stage.addChild(child); + + app.destroy(true, true); + expect(child.transform).to.be.null; + }); + describe('resizeTo', function () { before(function ()