diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e3729348168..422b10e36e88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Changelog ##### Unreleased +- `(Async)DisposableStack.prototype.move` marks the original stack as disposed, [#1226](https://github.com/zloirock/core-js/issues/1226) - Compat data improvements: - [`URLSearchParams.prototype.size`](https://github.com/whatwg/url/pull/734) marked as supported from FF112, NodeJS 19.8 and Deno 1.32 - Added Deno 1.32 compat data mapping diff --git a/packages/core-js/modules/esnext.async-disposable-stack.constructor.js b/packages/core-js/modules/esnext.async-disposable-stack.constructor.js index a8a705770c7e..90c675165ddd 100644 --- a/packages/core-js/modules/esnext.async-disposable-stack.constructor.js +++ b/packages/core-js/modules/esnext.async-disposable-stack.constructor.js @@ -110,6 +110,8 @@ defineBuiltIns(AsyncDisposableStackPrototype, { var newAsyncDisposableStack = new $AsyncDisposableStack(); getAsyncDisposableStackInternalState(newAsyncDisposableStack).stack = internalState.stack; internalState.stack = []; + internalState.state = DISPOSED; + if (!DESCRIPTORS) this.disposed = true; return newAsyncDisposableStack; } }); diff --git a/packages/core-js/modules/esnext.disposable-stack.constructor.js b/packages/core-js/modules/esnext.disposable-stack.constructor.js index 610dec8beb2a..6ed7ce7aef52 100644 --- a/packages/core-js/modules/esnext.disposable-stack.constructor.js +++ b/packages/core-js/modules/esnext.disposable-stack.constructor.js @@ -94,6 +94,8 @@ defineBuiltIns(DisposableStackPrototype, { var newDisposableStack = new $DisposableStack(); getDisposableStackInternalState(newDisposableStack).stack = internalState.stack; internalState.stack = []; + internalState.state = DISPOSED; + if (!DESCRIPTORS) this.disposed = true; return newDisposableStack; } }); diff --git a/tests/unit-global/esnext.async-disposable-stack.constructor.js b/tests/unit-global/esnext.async-disposable-stack.constructor.js index d6f0aaa99af3..ff437dad2a87 100644 --- a/tests/unit-global/esnext.async-disposable-stack.constructor.js +++ b/tests/unit-global/esnext.async-disposable-stack.constructor.js @@ -106,15 +106,9 @@ QUnit.test('AsyncDisposableStack#move', assert => { const stack2 = stack1.move(); - assert.false(stack1.disposed); + assert.true(stack1.disposed); - return stack1.disposeAsync().then(() => { - assert.same(result, ''); - - assert.true(stack1.disposed); - - return stack2.disposeAsync(); - }).then(() => { + return stack2.disposeAsync().then(() => { assert.same(result, '12'); }); }); diff --git a/tests/unit-global/esnext.disposable-stack.constructor.js b/tests/unit-global/esnext.disposable-stack.constructor.js index 055e64bd9aa0..fe3ba72a0208 100644 --- a/tests/unit-global/esnext.disposable-stack.constructor.js +++ b/tests/unit-global/esnext.disposable-stack.constructor.js @@ -99,12 +99,6 @@ QUnit.test('DisposableStack#move', assert => { const stack2 = stack.move(); - assert.false(stack.disposed); - - stack.dispose(); - - assert.same(result, ''); - assert.true(stack.disposed); stack2.dispose(); diff --git a/tests/unit-pure/esnext.async-disposable-stack.constructor.js b/tests/unit-pure/esnext.async-disposable-stack.constructor.js index c8f3f09d350c..15373accda3b 100644 --- a/tests/unit-pure/esnext.async-disposable-stack.constructor.js +++ b/tests/unit-pure/esnext.async-disposable-stack.constructor.js @@ -105,15 +105,9 @@ QUnit.test('AsyncDisposableStack#move', assert => { const stack2 = stack1.move(); - assert.false(stack1.disposed); + assert.true(stack1.disposed); - return stack1.disposeAsync().then(() => { - assert.same(result, ''); - - assert.true(stack1.disposed); - - return stack2.disposeAsync(); - }).then(() => { + return stack2.disposeAsync().then(() => { assert.same(result, '12'); }); }); diff --git a/tests/unit-pure/esnext.disposable-stack.constructor.js b/tests/unit-pure/esnext.disposable-stack.constructor.js index c9f215b33850..73bd877fc480 100644 --- a/tests/unit-pure/esnext.disposable-stack.constructor.js +++ b/tests/unit-pure/esnext.disposable-stack.constructor.js @@ -97,12 +97,6 @@ QUnit.test('DisposableStack#move', assert => { const stack2 = stack1.move(); - assert.false(stack1.disposed); - - stack1.dispose(); - - assert.same(result, ''); - assert.true(stack1.disposed); stack2.dispose();