Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

1.3.0-beta.17 still has issues with SVG and directives #8494

Closed
@benlesh

Description

@benlesh

I'll leave this to @IgorMinar or @tbosch to break down, but here are the issues I see with the current implementation of SVG handling with directives:

Transclusion is a problem

Transcluded content doesn't always behave nicely when switching namespaces. This is because it relies heavily on .cloneNode which, in the case of custom elements inside of SVG is going to clone "broken" elements that SVG doesn't know what to do with. The only reliable way to transclude arbitrary HTML/SVG fragments that may or may not include custom elements is to use a wrapMap.

Attribute binding is a problem in directive templates

When evaluating a directive template, attributes bound with the {{x}} syntax cause browser errors when rendering the element (in console: Error: Invalid value for <circle> attribute cx="{{x}}"). SVG Elements are pretty strict about what they allow. The following throw errors: <path d=""> <rect x="{{foo}}">, or pretty much anything with an attribute equal to {{bindThing}} that happens to be an svg string attribute. The case of path[d] is an interesting and unique one, because while I'm sure it won't be often bound to, it expects at least valid path data of M0,0.

Here's a JSBin that demonstrates all of the behaviors mentioned.

I've sent an email with some ideas and discussion around this issue to @IgorMinar, and I'm happy to help in any way I can with this effort. There has been some discussion around re-creating the Ember-based composable graphing components I've created for Netflix in Angular for use in other existing Angular projects at Netflix, however the problems listed above would make it extremely difficult to do.

Edit: looks like ng-attr- fixes most of the attribute issues.

path="" breaking is still a unique one, but probably not worth a special work around.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions