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

Add support for breaking <svg> into templates #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cray0000
Copy link
Member

Add svg option into templates definition which instructs parser to treat all elements in this template as svg:

<index:>
  <svg>
    <g>
      {{each @points as #point}}
        <view is='point' />
      {{/}}
    </g>
  </svg>

<point: svg>
  <g>
    <circle cx='{{ #point.x }}' cy='{{ #point.y }}' r='{{ #point.r }}' />
    <text x='{{ #point.x }}' y='{{ #point.y }}'>{{ #point.label }}</text>
  </g>

Currently if you try to break <svg> into templates it won't show elements from those templates at all because the information about them being part of <svg> is lost and it creates them via document.createElement() instead of document.createElementNS().

So this pull request fixes it. Though I think it should be possible to get rid of the explicit svg in template declaration if we modify the Element.prototype.appendTo() to figure out on execution time whether the element has the <svg> ancestor or not.

… that all dom elements in this template are svg elements. This allows to break <svg> into templates/components.
@cray0000
Copy link
Member Author

oh, didn't notice that there is already #4, so this pull request is similar to #5, though it implements another solution proposed by @enjalot in #5 (comment) by marking the whole template as svg.

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

Successfully merging this pull request may close these issues.

1 participant