vuejs / core

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
https://vuejs.org/
MIT License
46.8k stars 8.21k forks source link

Vue fails to mount in environments that don't provide window.SVGElement #3590

Open xinix opened 3 years ago

xinix commented 3 years ago

Version

3.0.11

Reproduction link

https://github.com/xinix/vue3-svg-bug

Steps to reproduce

Create a sample Vue3 app with Vue UI:

vue create demo

Select the following:

npm install 
npm run test:unit

What is expected?

Sample test to run

What is actually happening?

An error is thrown:

ReferenceError: SVGElement is not defined
    at Object.app.mount (dist/js/webpack:/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js:1259:1)
    at mount (dist/js/webpack:/node_modules/@vue/test-utils/dist/vue-test-utils.esm-bundler.js:2310:1)
    at shallowMount (dist/js/webpack:/node_modules/@vue/test-utils/dist/vue-test-utils.esm-bundler.js:2329:1)
    at Context.<anonymous> (dist/js/webpack:/tests/unit/example.spec.ts:8:1)
    at processImmediate (internal/timers.js:461:21)
LinusBorg commented 3 years ago

https://github.com/vuejs/vue-cli/pull/6400

Will be fixed in the next version of the mocha vue cli plugin.

LinusBorg commented 3 years ago

On second though, we might want to consider making this more robust in Vue core. I'll reopen for further evalution.

HcySunYang commented 3 years ago

Does this really need a fix? For runtime-dom, we assume that it runs in a standard browser environment.

LinusBorg commented 3 years ago

Probably not. Wanted to check out why it was a problem on vue-cli durting testing with mocha though, before I close it.

fangbinwei commented 3 years ago

I think it's similar to https://github.com/vuejs/vue-next/pull/2943