Skip to content

Commit b203263

Browse files
authoredAug 1, 2023
fix(runtime): forceUpdate calls only execute when in a browser env (#4591)
* `forceUpdate` calls only execute when in a browser env * update testing platform build conditionals * fmt * fix an e2e test
1 parent e32583a commit b203263

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed
 

‎src/runtime/test/globals.spec.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ describe('globals', () => {
3333
});
3434

3535
it('build values', () => {
36-
expect(Build.isBrowser).toBe(false);
36+
expect(Build.isBrowser).toBe(true);
3737
expect(Build.isDev).toBe(true);
3838
expect(Build.isTesting).toBe(true);
39+
expect(Build.isServer).toBe(false);
3940
});
4041

4142
it('Env is defined', () => {

‎src/runtime/update-component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BUILD, NAMESPACE } from '@app-data';
2-
import { consoleError, doc, getHostRef, nextTick, plt, win, writeTask } from '@platform';
2+
import { Build, consoleError, doc, getHostRef, nextTick, plt, win, writeTask } from '@platform';
33
import { CMP_FLAGS, HOST_FLAGS } from '@utils';
44

55
import type * as d from '../declarations';
@@ -362,7 +362,7 @@ export const postUpdateComponent = (hostRef: d.HostRef) => {
362362
};
363363

364364
export const forceUpdate = (ref: any) => {
365-
if (BUILD.updatable) {
365+
if (BUILD.updatable && Build.isBrowser) {
366366
const hostRef = getHostRef(ref);
367367
const isConnected = hostRef.$hostElement$.isConnected;
368368
if (

‎src/testing/platform/testing-build.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type * as d from '@stencil/core/internal';
22

33
export const Build: d.UserBuildConditionals = {
44
isDev: true,
5-
isBrowser: false,
6-
isServer: true,
5+
isBrowser: true,
6+
isServer: false,
77
isTesting: true,
88
};

‎test/end-to-end/src/build-data/build-data.spec.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { BuildData } from './build-data';
21
import { newSpecPage } from '@stencil/core/testing';
32

3+
import { BuildData } from './build-data';
4+
45
describe('build-data', () => {
56
it('should be a test', async () => {
67
const { root } = await newSpecPage({
@@ -10,7 +11,7 @@ describe('build-data', () => {
1011
expect(root).toEqualHtml(`
1112
<build-data>
1213
<p>isDev: true</p>
13-
<p>isBrowser: false</p>
14+
<p>isBrowser: true</p>
1415
<p>isTesting: true</p>
1516
</build-data>
1617
`);

0 commit comments

Comments
 (0)
Please sign in to comment.