Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Translate directive not working in SVG on Safari #717

Closed
27leaves opened this issue Sep 10, 2014 · 7 comments
Closed

Translate directive not working in SVG on Safari #717

27leaves opened this issue Sep 10, 2014 · 7 comments
Milestone

Comments

@27leaves
Copy link

Hi!

I have the following problem: It seems that the translate directive is not working in Safari inside an SVG text element. In Chrome it works as expected. The filter works in Safari, too.

Demo: http://plnkr.co/edit/Hxz0XNTvmqI8Wz3MWqEB?p=preview

@knalli knalli added the bug label Sep 11, 2014
@knalli
Copy link
Member

knalli commented Sep 11, 2014

Yes, looks like a Safari problem. I can confirm I see the exception, but I'm unable to debug this right now. The developer tools are broken for me, do not know if this is only by me or a general issue on Safari atm.

@knalli
Copy link
Member

knalli commented Sep 11, 2014

The problem lies here:

var translateValueExist = tElement[0].outerHTML.match(/translate-value-+/i);
there is a npe or so..

@tspaeth
Copy link
Member

tspaeth commented Sep 14, 2014

Here is some information on that:
http://stackoverflow.com/questions/12592417/outerhtml-of-an-svg-element

In case of a missing implementation in the browser, we can copy the dom(part), create a fake node around the target element and then take the innerHTML of that as the "outerHTML"...

@pedrosanta
Copy link

Yep, got that issue too. Using the translate filter works though.

@knalli knalli added this to the 2.7.1 milestone May 2, 2015
@knalli knalli modified the milestones: 2.7.2, 2.7.1 Jun 1, 2015
knalli added a commit to knalli/angular-translate that referenced this issue Jun 1, 2015
@knalli knalli closed this as completed Jun 5, 2015
@Pumpuli
Copy link

Pumpuli commented Sep 7, 2015

This is still broken in IE. Reason is the same:

var translateValueExist = tElement[0].outerHTML.match(/translate-value-+/i);
SVG elements don't have outerHTML. Or at least they didn't have, and that's still true in IE11.

@rcollette
Copy link

We're seeing that using data-translate directive does not work in Chrome either, despite the applied fix.

@ScallyGames
Copy link

From the linked SO post adding this polyfill

Object.defineProperty(SVGElement.prototype, 'outerHTML', {
    get: function () {
        var $node, $temp;
        $temp = document.createElement('div');
        $node = this.cloneNode(true);
        $temp.appendChild($node);
        return $temp.innerHTML;
    },
    enumerable: false,
    configurable: true
});

seems to fix this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants