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

Reorganize SVG attributes in the style of HTML attributes #9462

Open
ddbeck opened this issue Mar 15, 2021 · 5 comments
Open

Reorganize SVG attributes in the style of HTML attributes #9462

ddbeck opened this issue Mar 15, 2021 · 5 comments
Labels
data:svg Compat data for SVG features. https://developer.mozilla.org/docs/Web/SVG idle Issues and pull requests with no recent activity question Issues where a question or problem is stated and a discussion is held to gather opinions.

Comments

@ddbeck
Copy link
Collaborator

ddbeck commented Mar 15, 2021

SVG element attributes are organized in a different way from HTML element attributes. Many SVG attributes are recorded as svg.attributes.<category>.<attribute> while others are recorded as svg.elements.<element>.<attribute>. Some are recorded in both places. This is confusing and leads to duplicate or mismatched data.

Instead, I propose we adopt the somewhat more consistent pattern of HTML element attributes for SVG attribute data: svg.elements.<attribute> for attributes which apply to a single element and svg.global_attributes.<attribute> for attributes which are not element-specific.

If we were to do this, we'd probably need to

  • write up a guideline documenting the new approach
  • go through all the existing SVG attributes and determine which are duplicates or need to be relocated
  • update MDN pages with new identifiers

I don't think this is particularly high priority at the moment, but if we could agree on an approach in general, then we could leave it open as an effort that the community could pick up incrementally.

Inspired by #9402.

@ddbeck ddbeck added question Issues where a question or problem is stated and a discussion is held to gather opinions. data:svg Compat data for SVG features. https://developer.mozilla.org/docs/Web/SVG labels Mar 15, 2021
@github-actions github-actions bot added the idle Issues and pull requests with no recent activity label May 25, 2022
@foolip
Copy link
Contributor

foolip commented Jun 5, 2024

This has come up again in openwebdocs/mdn-bcd-collector#1474.

https://svgwg.org/svg2-draft/attindex.html doesn't defined what global attributes are, but the attributes that are valid on the most elements are the ones in https://svgwg.org/svg2-draft/struct.html#CommonAttributes: id, tabindex, autofocus, lang, xml:space, class and style. A good starting point would be calling those global attributes and reorganize the rest.

@queengooborg
Copy link
Contributor

This has been partially done in #22267, where the attributes were flattened into global_attributes. However, we still need to pick out the attributes that are not global, and move them to the corresponding elements.

@Elchi3
Copy link
Member

Elchi3 commented Jun 27, 2024

In SVG there are also Presentation Attributes: https://svgwg.org/svg2-draft/styling.html#PresentationAttributes

The spec says that the following attributes apply to "Any element in the SVG namespace". I guess that makes them "global". They can also all be used as CSS properties.

alignment-baseline, baseline-shift, clip-path, clip-rule, color,color-interpolation, color-interpolation-filters, cursor,direction, display, dominant-baseline, fill-opacity, fill-rule,filter, flood-color, flood-opacity, font-family, font-size, font-size-adjust, font-stretch, font-style, font-variant, font-weight,glyph-orientation-horizontal, glyph-orientation-vertical,image-rendering, letter-spacing, lighting-color, marker-end,marker-mid, marker-start, mask, mask-type, opacity,overflow, paint-order, pointer-events, shape-rendering,stop-color, stop-opacity, stroke, stroke-dasharray, stroke-dashoffset, stroke-linecap, stroke-linejoin, stroke-miterlimit,stroke-opacity, stroke-width, text-anchor, text-decoration,text-overflow, text-rendering, transform-origin, unicode-bidi,vector-effect, visibility, white-space, word-spacing, writing-mode

@caugner
Copy link
Contributor

caugner commented Jan 8, 2025

The spec says that the following attributes apply to "Any element in the SVG namespace".

I checked all of them and found that only mask-type is missing: #25608

@caugner
Copy link
Contributor

caugner commented Jan 8, 2025

I also checked all attributes currently recorded under svg.global_attributes (see #25609), and only found the following attributes that appear to be strictly speaking not global, but still apply to the majority of elements:

  • requiredExtensions ("Most elements, but not all, may have conditional processing attributes [like requiredExtensions] specified on them.", which excludes never-rendered elements like style/script)
  • clip (SVG 2 refers to CSS Masking 1: "applies to elements which establish a new viewport, pattern and mask elements")
  • transform (SVG 2 points to CSS Transforms 1, which mentions "applies to: transformable elements")

@Elchi3 What should we do with these?

PS: Is there a reason why we have all svg global attributes in a single JSON file, rather than one file per attribute?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:svg Compat data for SVG features. https://developer.mozilla.org/docs/Web/SVG idle Issues and pull requests with no recent activity question Issues where a question or problem is stated and a discussion is held to gather opinions.
Projects
None yet
Development

No branches or pull requests

5 participants