angular / angular.js

AngularJS - HTML enhanced for web apps!
https://angularjs.org
MIT License
58.83k stars 27.51k forks source link

ng-href behavior to add xlink:href as well as href attributes in SVG - USE #15618

Open kamlekar opened 7 years ago

kamlekar commented 7 years ago

Do you want to request a feature or report a bug? I am not sure whether this is a bug or request for new feature.

What is the current behavior? I was using inline svg like:

<svg> 
    <use xlink:href="#logo"></use>
</svg>

But then I came to know that xlink:href attribute is deprecated. and in future, use will support href attribute. So, to support both modern and bit old browsers, I was using the following code (which is working):

<svg> 
    <use xlink:href="#logo" href="#logo"></use>
</svg>

Then I made this to a directive. So that I can manage this code easily. In directive's html, I wrote the code as follows:

    <svg> 
        <use ng-href="{{ '#' + svgHref }}" xlink:href=""></use>
    </svg>

This is generating the HTML to:

    <svg> 
        <use ng-href="#logo" xlink:href="#logo"></use>
    </svg>

As you can see, the href attribute is missing which I was thinking that ng-href will handle automatically.

Current Angular Version: 1.6.1

gkalpak commented 7 years ago

The current implementation works as expected, so this is a feature request. Note that:

  1. The deprecation of the xlink namespace was introduced in SVG v2, which is currently a Candidate Recommendation (i.e. work in progress and subject to change).
  2. According to the spec, even if deprecated, xlink:href should also be recognized by elements with an ‘href’ attribute.

Considering that, I don't feel compelled to update the implementation asap. But if someone feels strongly about it, I guess it wouldn't hurt to update both attributes, so feel free to submit pull requests.

matthewchivers commented 6 years ago

who wants a fucking row then