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

Support Fabric in XML documents. #5530

Closed
ajvincent opened this issue Feb 20, 2019 · 5 comments
Closed

Support Fabric in XML documents. #5530

ajvincent opened this issue Feb 20, 2019 · 5 comments

Comments

@ajvincent
Copy link
Contributor

ajvincent commented Feb 20, 2019

Fabric.js assumes that it runs inside a HTML document. Which is usually not a bad assumption, but it does mean if I try to load Fabric in a XML document, it just breaks all over the place. In particular, when referring to properties of element.style, it throws exceptions because element is an instance of Element, not HTMLElement. The latter has the style property; the former does not.

Fortunately the fix is simple: in HEADER.js, I use fabric.document = document.implementation.createHTMLDocument(""); to make this work (in the case where document isn't a HTMLDocument). I will provide a pull request momentarily.

I can provide a testcase upon request, written in SVG and using the <foreignObject> element. (I know, I know, why use FabricJS and Canvas if I have SVG? Well, I have my reasons - specifically, being able to capture a video stream in the browser from the canvas.) In general, though, I think the pull request I will generate will work with any XML document.

@ajvincent
Copy link
Contributor Author

ajvincent commented Feb 20, 2019

editor.zip
This has the SVG file and a FabricController.js, and assumes the existence of libraries/fabric/fabric.js .

In particular, it renders differently in Mozilla Firefox and Google Chrome: in Firefox there is a red dot above the canvas element. In Chrome, there isn't. That's more likely to be a browser behavior, though, not a Fabric bug.

@asturur
Copy link
Member

asturur commented Feb 20, 2019

i ll try the editor.zip, understand the use case and probably merge.

@ghost
Copy link

ghost commented May 23, 2019

This breaks IE10 and IE9: both do not support HTMLDocument.
Now I have to go back to 2.6.0

@asturur
Copy link
Member

asturur commented May 23, 2019

ie9 is no more supported since 2.0
Ie10 there is a PR to restore functionality, if you would be able to test it, i can merge it.

@asturur
Copy link
Member

asturur commented May 23, 2019

#5678

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

No branches or pull requests

2 participants