Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown custom element: <foreignObject> #11575

Closed
ThomasR opened this issue Aug 7, 2020 · 1 comment · Fixed by #11576
Closed

Unknown custom element: <foreignObject> #11575

ThomasR opened this issue Aug 7, 2020 · 1 comment · Fixed by #11576

Comments

@ThomasR
Copy link

ThomasR commented Aug 7, 2020

Version

2.6.11

Reproduction link

https://jsfiddle.net/0jh1psog/

Steps to reproduce

Open the console in the provided JSFiddle
or
run Vue.config.getTagNamespace('foreignObject')

What is expected?

Vue.config.getTagNamespace('foreignObject') should return 'svg'

What is actually happening?

It returns undefined.

This causes a warning Unknown custom element: <foreignObject> when testing such components using vue-test-utils


This is caused by

'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +

It should be foreignobject with lowercase o here, because of the makeMap implementation.

To avoid such bugs in the future, even better fix:

map[list[i]] = true

should be map[expectsLowerCase ? list[i].toLowerCase() : list[i]] = true

@ThomasR
Copy link
Author

ThomasR commented Aug 7, 2020

Workaround (can go for example in one of your Jest setup files):

import Vue from 'vue';
const { getTagNamespace } = Vue.config;
Vue.config.getTagNamespace = (tag) => {
   if (tag.toLowerCase() === 'foreignobject') {
        return 'svg';
    }
    return getTagNamespace(tag);
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants