Skip to content

Commit 26e22d0

Browse files
fix: isTrustedSignal/Context should return false when there is no trusted set
1 parent 9e4d3fa commit 26e22d0

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ describe('context', () => {
9696
expect(isTrustedContext({})).toBe(false);
9797
});
9898

99-
it('should return true for all calls when trustedContexts is not set', () => {
100-
expect(isTrustedContext({})).toBe(true);
99+
it('should return false for all calls when trustedContexts is not set', () => {
100+
expect(isTrustedContext({})).toBe(false);
101101
});
102102
});
103103
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ describe('signals', () => {
5353
expect(isTrustedSignal({})).toBe(false);
5454
});
5555

56-
it('should return true for all calls when trustedSignals is not set', () => {
57-
expect(isTrustedSignal({})).toBe(true);
56+
it('should return false for all calls when trustedSignals is not set', () => {
57+
expect(isTrustedSignal({})).toBe(false);
5858
});
5959
});
6060
});

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,13 @@ export function setTrustedContextSet(context: WeakSet<object>) {
4747
}
4848

4949
export function addTrustedContext(contextParticipant: object) {
50-
// This should be a no-op when the trustedSignals set isn't set by runtime
50+
// This should be a no-op when the trustedContext set isn't set by runtime
5151
trustedContext?.add(contextParticipant);
5252
}
5353

5454
export function isTrustedContext(target: object): boolean {
5555
if (!trustedContext) {
56-
// The runtime didn't set a trustedContext set
57-
// this check should only be performed for runtimes that care about filtering context participants to track
58-
return true;
56+
return false;
5957
}
6058
return trustedContext.has(target);
6159
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ export function addTrustedSignal(signal: object) {
2121

2222
export function isTrustedSignal(target: object): boolean {
2323
if (!trustedSignals) {
24-
// The runtime didn't set a trustedSignals set
25-
// this check should only be performed for runtimes that care about filtering signals to track
26-
// our default behavior should be to track all signals
27-
return true;
24+
return false;
2825
}
2926
return trustedSignals.has(target);
3027
}

0 commit comments

Comments
 (0)