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

Polyfill makes changes to the DOM beyond the image editor component #706

Open
cgratie opened this issue Feb 7, 2022 · 3 comments
Open
Labels

Comments

@cgratie
Copy link

cgratie commented Feb 7, 2022

Describe the bug

The svgxuse polyfill makes changes to all the <use> tags in the document. This can break other functionality when the image editor is integrated into a larger project. It is also not compatible with React, because the DOM changes are likely to interfere with the reconciliation algorithm.

In my specific case this also creates a bug: SVG sprites used outside of the image editor are not loading in certain cases.

To Reproduce

1.import ImageEditor from '@toast-ui/react-image-editor'; somewhere inside a CRA webapp.
2. Somewhere else, use an SVG sprite as <svg><use href="https://url/of/svg#hash" /><svg>.
3. Start the dev server.
4. In the browser, set network throttling to 3G and reload the page.
5. The SVG sprite will not load. In the inspector we can also see that the href attribute has been overwritten to hold only "#hash".

Expected behavior

  • No change of the DOM that goes beyond the image editor component :)
  • OR the option to disable this polyfill when using React

Desktop (please complete the following information):

  • OS: [e.g. Ubuntu 20.04
  • Browser Chrome
  • Version 98

Additional context

In my project I have confirmed that the issue is directly related to this polyfill by editing the corresponding file to remove it.
I am also able to "disable" the polyfill with the following aggressive workaround:

window.MutationObserver = () => ({ observe: () => {} });
@cgratie cgratie added the Bug label Feb 7, 2022
@lja1018
Copy link
Contributor

lja1018 commented Feb 9, 2022

@cgratie
Thank you for the report.
The polyfill is required for external URL loading in IE. Therefore, a different approach is needed rather than the deletion of the polyfill.
It seems that the examples presented may be improved and used.

@cgratie
Copy link
Author

cgratie commented Feb 10, 2022

@lja1018
I see, thank you for the clarification.
So maybe a solution can be to apply the polyfill only for the case of IE (if it is not needed on other browsers)? Or, instead, to provide some config option for enabling/disabling it and let users of the package decide when to activate it.

@lja1018
Copy link
Contributor

lja1018 commented Feb 16, 2022

@cgratie
We will consider applying polyfill as an option.
Thank you.

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

No branches or pull requests

2 participants