]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix: should prefix `ShadowRoot` with `window.` (#2943)
authorHaoqun Jiang <haoqunjiang@gmail.com>
Wed, 3 Feb 2021 18:10:27 +0000 (02:10 +0800)
committerGitHub <noreply@github.com>
Wed, 3 Feb 2021 18:10:27 +0000 (19:10 +0100)
Otherwise this expression would throw in environments that does not
support `ShadowRoot` which includes the common mocha testing environment
setup that uses `jsdom` and `jsdom-global`.

It is because `ShadowRoot` is not an enumerable property on `window`,
`jsdom-global` fails to expose it on the `global` object.

See the error message at: https://app.circleci.com/pipelines/github/vuejs/vue-cli/779/workflows/17d7d7c4-7605-4588-878a-ddb3a6d37102/jobs/24147

packages/runtime-dom/src/index.ts

index 0dfe9fba003e9b61d8002c0ba20577c4f715de4e..027bef11be7cbc9fbe6affea17e8654669b194e3 100644 (file)
@@ -119,7 +119,7 @@ function normalizeContainer(
   }
   if (
     __DEV__ &&
-    container instanceof ShadowRoot &&
+    container instanceof window.ShadowRoot &&
     container.mode === 'closed'
   ) {
     warn(