-
Notifications
You must be signed in to change notification settings - Fork 132
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
Add support for the hidden
-attribute
#508
Comments
It seems very confusing to not allow it, especially, as outlined in the tweets above, when SVG is used inline in HTML. |
Found the tweet in which @AmeliaBR explained why it's not in the spec. |
This would be another case of synchronizing with One complications, is that we would need to decide precedence relative to regular presentation attributes. (CSS rules would override, same as for HTML elements.) As I mentioned to Michiel before, I really don't see a need for a new attribute in SVG. And I find it confusing that an attribute named But it is clearly a confusion for authors who expect it to be a universal attribute. This is especially likely if they have in the past used a compatibility rule in their stylesheet (for older browsers) that didn't distinguish by namespace: |
Thank you for your comments Amelia. Like you said, if nothing else, this will prevent a lot of confusion. |
The HTML standard suggests that |
Because that HTML user-agent stylesheet is restricted to HTML-namespaced elements using a CSS namespace rule: @namespace url(http://www.w3.org/1999/xhtml);
[hidden], area, base, basefont, datalist, head, link, meta, noembed,
noframes, param, rp, script, source, style, template, track, title {
display: none;
} One outcome of this issue would be to add a matching rule for SVG-namespaced elements, along with the global attribute and IDL property. |
<g hidden display="inline">
…
</g> The straightforward answer is probably(?) that
|
With an appropriate rule in the UA stylesheet (as "suggested" by HTML), [1] https://svgwg.org/svg2-draft/styling.html#PresentationAttributes |
Since HTML elements work with this attribute, I find it confusing that SVG elements in HTML documents don't. I personally think this attribute is useful and hope SVG elements would work with it, too. |
The SVG Working Group just discussed
The full IRC log of that discussion<krit> topic: Add support for the `hidden`-attribute<krit> GitHub: https://github.com//issues/508 <krit> AmeliaBR: This is about HTML consitency. HTML element allows hidden attributes on any element that Is usually mapped to disaplay: none. It is encouraged in HTML as a way to keep semantics in the markup instead of the stylesheet. <krit> AmeliaBR: In SVG we have presentation attributes to do this already. We didn't have a need for this attribute. But there might be confusion if we do not support it and people use it on SVG elements. Especially within CSS layout embedded in webpages/ <krit> krit: proposal is to add hidden attributes to all SVG elements? Or a list of elements? <krit> AmeliaBR: If we add them then to all elements. <krit> AmeliaBR: also for implementation complexity. My main concern is about wording and how it maps to display none or visibility properties. Or cascading attributes if you have this attribute and the regular presentation attributes. <krit> AmeliaBR: Attributes have no particular order so we need to define the priority. <AmeliaBR> HTML spec for hidden attribute: https://html.spec.whatwg.org/multipage/interaction.html#the-hidden-attribute <krit> nzimmermann: There is a note in the HTML spec that display: block will cancel the effect of the hidden attribute. So it has precedence over the hidden attributes. <krit> nzimmermann: So I don't think there is no issue with precedence with display or visibility. <krit> AmeliaBR: We still need to specify how attributes affect each other in SVG because that is not defined in HTML. But I agree with your logic to overwrite hidden attributes. <krit> nzimmermann: For authors it would make sense to have an explicit definition how attributes affect each other. <krit> AmeliaBR: If we want to define the attributes in form of cascading it would override definition of presentation attributes. We can maybe ask for feedback from implementers what is easier to implement. And have a clear note in the spec how they relate <krit> nzimmermann: your concern was that attribute might override UA stylesheets? <krit> AmeliaBR: The opposite. <AmeliaBR> `svg|[hidden] {display: none}` <krit> AmeliaBR: The presentation attributes would be overridden <krit> nzimmermann: you are right. <krit> krit: what specific feedback we need from implementers? <krit> AmeliaBR: this was specifically about cascade issues. We just need to make sure it is clearly defined. <krit> krit: disagreement with being consistent with HTML and add hidden attributes?? <krit> krit: I need to look at it deeper. But it sounds like it is not just semantics but effects the styling <krit> AmeliaBR: Implementation is not that complicated. <krit> AmeliaBR: The semantic impact in fact of a11y is just coming out of the stylesheet. If I make something hidden it gets detected by accessibility software as well. <krit> AmeliaBR: I'd like to hear implementers commitment before adding it to SVG 2 but have no concerns with adding them in general. <krit> nzimmermann: no disagreement <krit> Tav_: no disagreement <krit> proposed RESOLUTION: Add a global hidden attribute to SVG with the same semantics as HTML that is expected to be implemented using UA stylesheets. <krit> RESOLUTION: Add a global hidden attribute to SVG with the same semantics as HTML that is expected to be implemented using UA stylesheets. Iff there is implementation commitment <krit> AmeliaBR: Who would be doing the work? <krit> AmeliaBR: Will ask Zoe |
@ZoeBijl, would you be interested in starting a PR for this? (It would follow an existing pattern used for e.g. tabindex, where we just reference HTML for the detailed definitions.) I'd be happy to help as needed. |
Following the painful discussion in whatwg/html#4904 I’m not so sure. To rephrase: I’m not sure this should be supported given the definition for the I’ve gone from fan of the |
Hmm… hadn't seen that discussion on WHATWG HTML. I'd still say there is a use, as an authoring convenience, to support |
One use case I can think of is having a hidden Under the (now defunct) W3C HTML 5.2 spec definition I would be totes in favour of this. My aim with this issue was to reduce the confusion for authors. With the WHATWG definition I’m not sure allowing the |
This hasn’t been discussed in a while but I thought it’d be worth following up on this thread based on a possible issue I foresee with
If those types of widely-used resets remove their This will be be pretty straightforward for maintainers of CSS resets and authors generally to resolve, but I thought it worth mentioning here nonetheless. I personally found out about this because Tailwind CSS removed this override from their reset for the reasons I mention above. For context, I use the <svg hidden>
<defs>
<symbol id="circle"><circle cx="8" cy="8" r="7" /></symbol>
</defs>
</svg>
<svg class="inline" width="16" height="16"><use href="#circle"></use></svg>Test |
In the past I've run into the lack of support for the
hidden
-attribute in SVG a few times. Today I saw a tweet that mentions this lack too. Were there ever plans to include support? And if not, are there good reasons not to include it?The text was updated successfully, but these errors were encountered: