-
Notifications
You must be signed in to change notification settings - Fork 27.4k
1.3 : Requiring <base> tags means I can't use SVG with clip-path, mask, etc... #8934
Comments
You shold be able to use a full URL (including scheme + host + path) for these --- the browser won't rewrite those relative to the <base> tag. As for undoing it, well we tried something else first, but unfortunately the alternative had more problems. I agree that it really sucks that the <base> tag is so coupled with the application base url in angular, but there's little we can do about it without making things even worse :( |
You could go bug anne van kesteren about it though :p maybe he'll let us have multiple base tags in the future, for different things |
/cc @tbosch |
I wish it were that easy. When I try that, the SVG icons look fine on initial page load however the first time I navigate to a different page within the application, all the clipping goes away. The clipping only works on the initially loaded page because that is the full path that is used in the SVG. The SVG icons are not getting recompiled or anything like that (using ui-router in order to have certain view that don't change when moving around the application). I assume this is because once I navigate to a new page, the SVG no longer can find the element (since the full url does not match the new url after the initial page load). |
Yes, that's more of a problem... I'll see if there's anything we can do about that without reverting the location fixes |
Could you like, provide a reproduction to what you're talking about (wrt to clipping being broken)? I'm not really getting that --- even just showing the markup of your svg would be helpful |
@caitp http://plnkr.co/edit/ykU211Qgx2HczNnM5LXY?p=preview With http://plnkr.co/edit/syDHyECUmo5aJyw7LzwI?p=preview The SVG has a mask and is generated with Sketch but I believe most vector software will export similar to this. |
Thanks --- so yes, changing the mask URI to an absolute url does work around it... could probably write a quick tool to do that for you. I don't think we can really do that in core though ._. You can author the SVG differently though, using paths instead of --- it's a bit of a heavier transfer, but it should work for you. |
I'm not sure we'd be wise to automate changing FuncIRI notation on route change though :( |
Digging into more, it seems like it has to do with the library I am using for SVG icons, Iconic. When I remove the iconic.js library that is being used to load the icons and fallback to the SVGInjector library, route switching no longer effect the icons properties that use url() (though I still need to add the absolute url to the beginning which is not that big of an issue). I still hate the fact that 1.3 requires the |
Hi, The major problem with html5mode and not having a The problem with svg attributes that use See this plunker: http://plnkr.co/edit/yRChhan8SB5fQIy9BmjC?p=preview Also note that changing the path via the history API AFTER the svg has been loaded does not seem a problem! |
Ah, calling |
One solution could be: Create a directive for all of the SVG properties that are allows to use a |
To make this more concrete:
Anyone would like to make a PR for this? |
@tbosch I'll take a stab at a PR |
Could you check whether our solution also works in FF using the Plunker and On Thursday, September 11, 2014, Jeff Cross notifications@github.com
|
The spec for svg 1.1 linking seems to ("seems to" = "I'm not the best at parsing specs") indicate that the FuncIRI notation (attr="url(...)") should respect the document's base tag, in the order of priority supported by xml:base tag. However, issue 34 on the SVG2 draft indicates that the document's base tag's impact on SVG isn't clearly speced. I'm experimenting with adding xml:base to different self/parent svg elements in the plnkr, but haven't yet been able to get it to do what I want. |
Actually it seems that Chrome doesn't honor xml:base, but Firefox does. |
@jeffbcross, thanks! $locationProvider.html5Mode({enabled: true, requireBase: false} works for me |
@jeffbcross Thanks a lot for this! |
- So that clip paths work in cases where <base> is set, for example in some version of AngularJS angular/angular.js#8934
Due to this issue angular/angular.js#8934 (comment) we were using absolute paths to reference clips. Unfortunately this stopped working as soon as we started using deep linking on the visualize page. Instead, an update to the issue means we can drop support for IE9 and remove some of the need for the `<base>` element. Fixes #272
Thanks. |
Using fix specified here: angular/angular.js#8934 (comment) Fixes meanjs#1224, Fixes meanjs#1230
This may be useful for anyone running into this who still wants to have a
in template (example):
I don't know if there's anything about 'fill' that means this won't work with 'mask' or 'clip-path', but $location.absUrl() will provide the current URL for any dynamically changing url, and it works for me |
angular/angular.js#8934 here is where this was closed
With the recent change of requiring the
<base>
tag, now all my SVG icons that I use that have clip-paths, masks, etc... are broken. I can't set the urls for those properties to absolute paths because the url constantly changes when navigate in the app and I can't set relative urls because of the<base>
now. The only thing I can do is not use HTML5 mode which I just don't like.I don't see why the
<base>
tag should be required when historically from what I read it generally causes more issues than is solves (like this one). As far as linking goes, I can't think of a reason they should not all start with a/
. There is no reason I can think of where when on/page1
and you want to link to/page2
you would need to have the link bepage2
. As far as the deep url issue, have that be something you can configure with $locationProvider or something.I really hope this change can be un-done or someone can tell me how to use SVG properties that require url() while still being able to HTML5 mode.
The text was updated successfully, but these errors were encountered: