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

fix($compile): use the correct namespace for transcluded svg elements #8816

Closed
wants to merge 1 commit into from

Conversation

tbosch
Copy link
Contributor

@tbosch tbosch commented Aug 28, 2014

This fixes the case when a directive that uses templateUrl
is used inside of a transcluding directive like ng-repeat.

Fixes #8808

tbosch referenced this pull request Aug 28, 2014
Via transclusion, svg elements can occur outside an `<svg>` container in an
Angular template but are put into an `<svg>` container through compilation
and linking.

E.g.
Given that `svg-container` is a transcluding directive with
the following template:
```
<svg ng-transclude></svg>
```

The following markup creates a `<circle>` inside of an `<svg>` element
during runtime:
```
<svg-container>
  <circle></circle>
</svg-container>
```

However, this produces non working `<circle>` elements, as svg elements
need to be created inside of an `<svg>` element.

This change detects for most cases the correct namespace of transcluded content
and recreates that content in the correct `<svg>` container
when needed during compilation. For special cases it adds an addition argument
to `$transclude` that allows to specify the future parent node of elements
that will be cloned and attached using the `cloneAttachFn`.

Related to #8494
Closes #8716
);
}
}
if (namespace !== 'html' && !$compileNodes[0]['$$namespace']) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.$$namespace

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we actually don't need this at all. just compare it to namespaceAdaptedCompileNodes[0]

This fixes the case when a directive that uses `templateUrl`
is used inside of a transcluding directive like `ng-repeat`.

Fixes angular#8808
@tbosch tbosch closed this Aug 29, 2014
@tbosch tbosch deleted the svg-transclusion branch August 29, 2014 00:34
tbosch added a commit that referenced this pull request Aug 29, 2014
This fixes the case when a directive that uses `templateUrl`
is used inside of a transcluding directive like `ng-repeat`.

Fixes #8808
Closes #8816
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When using svg directive with ngRepeat, the newly added element is not replaced with the directive template
3 participants