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

textPath Is Not Defined #223

Open
epihel opened this issue May 17, 2017 · 2 comments
Open

textPath Is Not Defined #223

epihel opened this issue May 17, 2017 · 2 comments

Comments

@epihel
Copy link

epihel commented May 17, 2017

Using react-templates 0.6.1 and react 15.5.4, the following code renders without errors:

render() { return ( <svg> <text> <textPath>txt</textPath> </text> </svg> ); };

But this SVG in an .rt file:
<text> <textPath>txt</textPath> </text>

compiles to:
React.createElement('text', {}, React.createElement(textPath, {}, 'txt'))

and produces the error "Uncaught ReferenceError: textPath is not defined." It looks like there should be quotes around "textPath."

According to React's documentation (https://facebook.github.io/react/blog/2016/04/07/react-v15.html), SVG elements are now fully supported. Is there a way to include textPath in rt files?

@nippur72
Copy link
Contributor

this could be quickly fixed by adding textPath to the list of SVG elements here.

As a workaround, until someone submits a PR, you could cheat by defining the variable textPath and let react render it as a native element:

let textPath = 'textPath';
...
<textPath></textPath>

or even in a scope:

<div rt-scope="'textPath' as textPath">
...
   <textPath></textPath>
...
</div>

@epihel
Copy link
Author

epihel commented May 18, 2017

Thank you for the rt-scope workaround. That worked. This then revealed a few more issues with the SVG attributes "xlink:href" and "clip-path," as well as the style attribute "clip-path", which react-templates currently passes through unchanged:

<path d="M 73,300 L 90,310" style="clip-path: url('url')"></path>

React gives the warnings:
"Unknown DOM property xlink:href. Did you mean xlinkHref?"
"Unknown DOM property clip-path. Did you mean clipPath?"

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