Skip to content

Commit

Permalink
fix(runtime): forceUpdate calls only execute when in a browser env (#…
Browse files Browse the repository at this point in the history
…4591)

* `forceUpdate` calls only execute when in a browser env

* update testing platform build conditionals

* fmt

* fix an e2e test
  • Loading branch information
tanner-reits committed Aug 1, 2023
1 parent e32583a commit b203263
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/runtime/test/globals.spec.tsx
Expand Up @@ -33,9 +33,10 @@ describe('globals', () => {
});

it('build values', () => {
expect(Build.isBrowser).toBe(false);
expect(Build.isBrowser).toBe(true);
expect(Build.isDev).toBe(true);
expect(Build.isTesting).toBe(true);
expect(Build.isServer).toBe(false);
});

it('Env is defined', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/update-component.ts
@@ -1,5 +1,5 @@
import { BUILD, NAMESPACE } from '@app-data';
import { consoleError, doc, getHostRef, nextTick, plt, win, writeTask } from '@platform';
import { Build, consoleError, doc, getHostRef, nextTick, plt, win, writeTask } from '@platform';
import { CMP_FLAGS, HOST_FLAGS } from '@utils';

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

export const forceUpdate = (ref: any) => {
if (BUILD.updatable) {
if (BUILD.updatable && Build.isBrowser) {
const hostRef = getHostRef(ref);
const isConnected = hostRef.$hostElement$.isConnected;
if (
Expand Down
4 changes: 2 additions & 2 deletions src/testing/platform/testing-build.ts
Expand Up @@ -2,7 +2,7 @@ import type * as d from '@stencil/core/internal';

export const Build: d.UserBuildConditionals = {
isDev: true,
isBrowser: false,
isServer: true,
isBrowser: true,
isServer: false,
isTesting: true,
};
5 changes: 3 additions & 2 deletions test/end-to-end/src/build-data/build-data.spec.ts
@@ -1,6 +1,7 @@
import { BuildData } from './build-data';
import { newSpecPage } from '@stencil/core/testing';

import { BuildData } from './build-data';

describe('build-data', () => {
it('should be a test', async () => {
const { root } = await newSpecPage({
Expand All @@ -10,7 +11,7 @@ describe('build-data', () => {
expect(root).toEqualHtml(`
<build-data>
<p>isDev: true</p>
<p>isBrowser: false</p>
<p>isBrowser: true</p>
<p>isTesting: true</p>
</build-data>
`);
Expand Down

0 comments on commit b203263

Please sign in to comment.