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

Serialization of transform functions and transform attribute. #932

Open
karlcow opened this issue Feb 2, 2024 · 0 comments
Open

Serialization of transform functions and transform attribute. #932

karlcow opened this issue Feb 2, 2024 · 0 comments

Comments

@karlcow
Copy link
Member

karlcow commented Feb 2, 2024

I'm in the process of creating some WPT tests for transform functions such as setScale(sx, sy) and setTranslate(tx, ty) because browsers send different results.

I want also to make sure that I get my analysis of serialization correct with regards to the attribute values.

Missing comma in Safari and Chrome

var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
var transform = svg.createSVGTransform();
transform.setScale(-2, -4);
g.transform.baseVal.appendItem(transform)
g.getAttribute('transform')

And the results are:

         IN             OUT
Safari:  scale(-2, -4)  scale(-2 -4)
Firefox: scale(-2, -4)  scale(-2, -4)
Chrome:  scale(-2, -4)  scale(-2 -4)

Modifying an existing transform attribute missing comma

data:text/html,<svg><g><circle r="100" transform="scale(2)"/></svg></g>

Then

const circle = document.querySelector("circle");
circle.getAttribute('transform');
// "scale(2)" everywhere
circle.transform.baseVal.getItem(0).setScale(3, 4)
circle.getAttribute('transform');
// "scale(3, 4)" in Firefox, "scale(3 4)" in Safari and Chrome
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

1 participant