-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($compile): use the correct namespace for transcluded svg elements #8716
Conversation
* | ||
* If no `type` is specified, then the type is considered to be html. | ||
* If no `templateNamespace` is specified, then the namespace is considered to be `html`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe templateNamespace
is a better name for this, but it's weird --- A) because these values are not actually namespaces, and B) because it's a breaking change for not much of a real reason given A).
If we're going to call it namespace
, the values should probably be proper XML namespaces, but we don't do this because people are going to have a much easier time remembering "svg" than "http://www.w3.org/2000/svg"
IMO we should change the symbol name within $compile --- so that the compiler is easier to understand, but the public api doesn't have an unneeded change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your are right, but I chatted with Igor to leave it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't have a better name than "namespace"... (type is really too general)
2d2fe9e
to
436d4d0
Compare
|
||
return boundTranscludeFn(scope, cloneAttachFn, transcludeControllers); | ||
if (!futureParentNode) { | ||
futureParentNode = hasElementTranscludeDirective ? $element.parent() : $element; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If futureParentNode
is changed to be a node (like its name implies) instead of a jQuery object then .parent()
can change to [0].parentNode
to avoid the extra jQuery object...
…espace` Also corrects the tests for MathML that use `directive.templateNamespace`. BREAKING CHANGE (within 1.3.0-beta): `directive.type` was renamed to `directive.templateNamespace` The property name `type` was too general.
35a7cab
to
623b5ca
Compare
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 angular#8494
623b5ca
to
1e5dd22
Compare
Via transclusion, svg elements can occur outside an
<svg>
container in anAngular template but are put into an
<svg>
container through compilationand linking.
E.g.
Given that
svg-container
is a transcluding directive withthe followingg template:
The following markup creates a
<circle>
inside of an<svg>
elementduring runtime:
However, this produces non working
<circle>
elements, as svg elementsneeds 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>
containerwhen needed during compilation. For special cases it adds an addition argument
to
$transclude
that allows to specify the future parent node of elementsthat will be cloned and attached using the
cloneAttachFn
.Related to #8494