Skip to content

Commit d395543

Browse files
chore: spec cleanup
1 parent b394e9e commit d395543

File tree

8 files changed

+14
-18
lines changed

8 files changed

+14
-18
lines changed

packages/@lwc/engine-core/src/framework/vm.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -804,12 +804,13 @@ function setupContext(vm: VM) {
804804
): void {
805805
renderer.registerContextConsumer(component, ContextEventName, {
806806
setNewContext: (contextVarieties: ContextVarieties) => {
807-
// If current context does not have the requested variety,
808-
// return false to continue traversing
809-
if (!contextVarieties.has(contextVariety)) {
810-
return false;
807+
if (contextVarieties.has(contextVariety)) {
808+
contextProvidedCallback(contextVarieties.get(contextVariety));
809+
return true;
811810
}
812-
contextProvidedCallback(contextVarieties.get(contextVariety));
811+
// Return false as context has not been found/consumed
812+
// and the consumer should continue traversing the context tree
813+
return false;
813814
},
814815
});
815816
},

packages/@lwc/engine-core/src/framework/wiring/context.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export function createContextProviderWithRegister(
5757
setDisconnectedCallback?.(disconnectCallback);
5858

5959
consumerConnectedCallback(consumer);
60+
return true;
6061
}
6162
);
6263
};
@@ -91,6 +92,7 @@ export function createContextWatcher(
9192
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
9293
// TODO: dev-mode validation of config based on the adapter.contextSchema
9394
callbackWhenContextIsReady(newContext);
95+
return true;
9496
},
9597
setDisconnectedCallback(disconnectCallback: () => void) {
9698
// adds this callback into the disconnect bucket so it gets disconnected from parent

packages/@lwc/engine-core/src/framework/wiring/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ export interface WireDebugInfo {
6262

6363
export type WireContextSubscriptionCallback = (
6464
subscriptionPayload: WireContextSubscriptionPayload
65-
) => boolean | void;
65+
) => boolean;
6666

6767
export interface WireContextSubscriptionPayload {
68-
setNewContext(newContext: ContextValue): boolean | void;
68+
setNewContext(newContext: ContextValue): boolean;
6969
setDisconnectedCallback?(disconnectCallback: () => void): void;
7070
}
7171

packages/@lwc/engine-dom/src/renderer/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type {
1616

1717
export class WireContextSubscriptionEvent extends CustomEvent<undefined> {
1818
// These are initialized on the constructor via defineProperties.
19-
public readonly setNewContext!: (newContext: WireContextValue) => false | void;
19+
public readonly setNewContext!: (newContext: WireContextValue) => boolean;
2020
public readonly setDisconnectedCallback?: (disconnectCallback: () => void) => void;
2121

2222
constructor(
@@ -62,7 +62,7 @@ export function registerContextProvider(
6262
onContextSubscription({
6363
setNewContext,
6464
setDisconnectedCallback,
65-
}) !== false
65+
})
6666
) {
6767
evt.stopImmediatePropagation();
6868
}

packages/@lwc/engine-server/src/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export function registerContextConsumer(
5757
const subscribeToProvider =
5858
currentNode[HostContextProvidersKey].get(adapterContextToken);
5959
if (!isUndefined(subscribeToProvider)) {
60-
// If context subscription is successful, top traversing to find a provider
61-
if (subscribeToProvider(subscriptionPayload) !== false) {
60+
// If context subscription is successful, stop traversing to locate a provider
61+
if (subscribeToProvider(subscriptionPayload)) {
6262
break;
6363
}
6464
}

packages/@lwc/integration-karma/helpers/test-utils.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,12 +722,10 @@ window.TestUtils = (function (lwc, jasmine, beforeAll) {
722722

723723
const connectContext = Symbol('connectContext');
724724
const disconnectContext = Symbol('disconnectContext');
725-
const contextEventKey = Symbol('contextEventKey');
726725

727726
const contextKeys = {
728727
connectContext,
729728
disconnectContext,
730-
contextEventKey,
731729
};
732730

733731
lwc.setContextKeys(contextKeys);

packages/@lwc/shared/src/__tests__/context.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ describe('context', () => {
2121
const mockContextKeys = {
2222
connectContext: Symbol('connect'),
2323
disconnectContext: Symbol('disconnect'),
24-
contextEventKey: Symbol('event'),
2524
};
2625

2726
setContextKeys(mockContextKeys);
@@ -30,20 +29,17 @@ describe('context', () => {
3029
expect(retrievedKeys).toBe(mockContextKeys);
3130
expect(retrievedKeys.connectContext).toBe(mockContextKeys.connectContext);
3231
expect(retrievedKeys.disconnectContext).toBe(mockContextKeys.disconnectContext);
33-
expect(retrievedKeys.contextEventKey).toBe(mockContextKeys.contextEventKey);
3432
});
3533

3634
it('should throw when attempting to set context keys multiple times', () => {
3735
const mockContextKeys1 = {
3836
connectContext: Symbol('connect1'),
3937
disconnectContext: Symbol('disconnect1'),
40-
contextEventKey: Symbol('event1'),
4138
};
4239

4340
const mockContextKeys2 = {
4441
connectContext: Symbol('connect2'),
4542
disconnectContext: Symbol('disconnect2'),
46-
contextEventKey: Symbol('event2'),
4743
};
4844

4945
setContextKeys(mockContextKeys1);

packages/@lwc/shared/src/context.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { isFalse } from './assert';
99
export type ContextKeys = {
1010
connectContext: symbol;
1111
disconnectContext: symbol;
12-
contextEventKey: symbol;
1312
};
1413

1514
let contextKeys: ContextKeys;

0 commit comments

Comments
 (0)