Skip to content

Commit

Permalink
(Async)DisposableStack.prototype.move marks the original stack as d…
Browse files Browse the repository at this point in the history
…isposed, close #1226
  • Loading branch information
zloirock committed Mar 23, 2023
1 parent 2e9df1e commit 3493e88
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
Expand Down
10 changes: 2 additions & 8 deletions tests/unit-global/esnext.async-disposable-stack.constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Expand Down
6 changes: 0 additions & 6 deletions tests/unit-global/esnext.disposable-stack.constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 2 additions & 8 deletions tests/unit-pure/esnext.async-disposable-stack.constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Expand Down
6 changes: 0 additions & 6 deletions tests/unit-pure/esnext.disposable-stack.constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3493e88

Please sign in to comment.