Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser breaking xml:href on svgs that use the "use" element in 2.1.2 #96

Closed
mattbucci opened this issue Jan 29, 2016 · 7 comments
Closed

Comments

@mattbucci
Copy link

I'm parsing my entire website, modifying assets to use a cdn

I've got svg elements like the following and when I save them the xlink:href of the use child is changed to just be href

<svg class="svg-icon icon__track">
   <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#svg-track"></use>
</svg>

<symbol id="svg-track" viewBox="0 0 42 42"><path d="M39.7 18.9c0-.1 0-.1 0 0v-.2-.1-.1-.1s0-.1-.1-.1c0 0 0-.1-.1-.1l-.1-.1-.1-.1h-.1s-.1 0-.1-.1l-2.8-1.3c-.5-.2-1 0-1.3.4-.2.5 0 1 .4 1.3l.7.3-12.7 4c-.1-.1-.2-.3-.3-.4l5-6.9c.4.2.9.3 1.4.3 2.1 0 3.7-1.7 3.7-3.7s-1.7-3.7-3.7-3.7c-1 0-2 .4-2.7 1.1L17 4l1-.2c.5-.2.8-.7.6-1.2-.1-.4-.6-.7-1.1-.6l-3 .9c-.1 0-.2.1-.3.2-.1.1-.2.2-.2.3 0 0 0 .1-.1.1V4l.9 3c.1.4.5.7.9.7h.3c.5-.2.8-.7.6-1.2l-.2-.8 9.7 5.3c-.1.4-.1.7-.1 1L9.2 16.6c-.6-1.1-1.9-1.9-3.2-1.9-2.1 0-3.7 1.7-3.7 3.7S4 22.1 6 22.1s3.7-1.7 3.7-3.7l16.7-4.5c.1.2.2.3.3.5l-5 6.9c-.4-.2-.9-.3-1.4-.3-2.1 0-3.7 1.7-3.7 3.7s1.7 3.7 3.7 3.7c.7 0 1.4-.2 2-.6l7.3 6.7c-.1.2-.2.5-.3.7l-9.5-.2c-.4-1.6-1.9-2.9-3.6-2.9-2.1 0-3.7 1.7-3.7 3.7 0 2.1 1.7 3.7 3.7 3.7 1.7 0 3.2-1.2 3.6-2.7l9.5.2c.4 1.6 1.9 2.9 3.6 2.9 2.1 0 3.7-1.7 3.7-3.7 0-2.1-1.7-3.7-3.7-3.7-.7 0-1.4.2-2 .6l-7.3-6.7c.3-.5.4-1.1.4-1.8v-.2l13-4-.4.8c-.2.5 0 1 .4 1.3.1.1.3.1.4.1.3 0 .7-.2.8-.5l1.3-2.8v-.1-.1-.1c.2 0 .2 0 .2-.1zM6 20.3c-1 0-1.9-.8-1.9-1.9S5 16.6 6 16.6s1.9.8 1.9 1.9S7 20.3 6 20.3zm23.7-10.1c1 0 1.9.8 1.9 1.9s-.8 1.9-1.9 1.9c-1 0-1.9-.8-1.9-1.9s.9-1.9 1.9-1.9zM18.5 24.7c0-1 .8-1.9 1.9-1.9 1 0 1.9.8 1.9 1.9s-.8 1.9-1.9 1.9c-1.1 0-1.9-.9-1.9-1.9zm-2.2 13.1c-1 0-1.9-.8-1.9-1.9 0-1 .8-1.9 1.9-1.9 1 0 1.9.8 1.9 1.9-.1 1.1-.9 1.9-1.9 1.9zm18.5-1.5c0 1-.8 1.9-1.9 1.9-1 0-1.9-.8-1.9-1.9 0-1 .8-1.9 1.9-1.9 1.1 0 1.9.9 1.9 1.9z"></path></symbol>

When parsing it here's what the xlink:href attribute itself looks like

screen shot 2016-01-29 at 3 06 58 pm

@mattbucci
Copy link
Author

@mattbucci
Copy link
Author

By Changing line 352 of OutputRules.php from

$name = $node->name;

to

$name = empty($node->prefix) ? $node->name : $node->prefix . ":" . $node->name;

I am able to resolve this issue.

I see your note

// XXX: The spec says that we need to ensure that anything in
            // the XML, XMLNS, or XLink NS's should use the canonical
            // prefix. It seems that DOM does this for us already, but there
            // may be exceptions.

I'm on PHP 5.4, I'm not sure if that helps. Let me know If I can give you any more information

@mattbucci
Copy link
Author

using $node = $node->nodeName; rather than $node = $node->name also seems to work

@technosophos
Copy link
Member

What does the HTML5 spec say about supporting xlink? I think it might be a
special case.

On Fri, Jan 29, 2016, 4:27 PM Matthew Bucci notifications@github.com
wrote:

using $node = $node->nodeName; rather than $node = $node->name also seems
to work


Reply to this email directly or view it on GitHub
#96 (comment)
.

@mattbucci
Copy link
Author

@technosophos Here's the mozilla foundation documentation on it

and the w3 spec as well

@mattfarina
Copy link
Member

@mattbucci does the fix in the pull request #97 fix this for you?

@mattbucci
Copy link
Author

@mattfarina yup, it sure does

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

No branches or pull requests

3 participants