, , ), , and text formatting elements (, , ). In reviewing #2118 (and as discussed on the call recorded in #2118 (..."> , , ), , and text formatting elements (, , ). In reviewing #2118 (and as d...">, , ), , and text formatting elements (, , ). In reviewing #2118 (and as d..."> Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Product GitHub Copilot Write better code with AI GitHub Models New Manage and compare prompts GitHub Advanced Security Find and fix vulnerabilities Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes Discussions Collaborate outside of code Code Search Find more, search less Explore Why GitHub All features Documentation GitHub Skills Blog Solutions By company size Enterprises Small and medium teams Startups Nonprofits By use case DevSecOps DevOps CI/CD View all use cases By industry Healthcare Financial services Manufacturing Government View all industries View all solutions Resources Topics AI DevOps Security Software Development View all Explore Learning Pathways Events & Webinars Ebooks & Whitepapers Customer Stories Partners Executive Insights Open Source GitHub Sponsors Fund open source developers The ReadME Project GitHub community articles Repositories Topics Trending Collections Enterprise Enterprise platform AI-powered developer platform Available add-ons GitHub Advanced Security Enterprise-grade security features Copilot for business Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. Include my email address so I can be contacted Saved searches Use saved searches to filter your results more quickly Name Query To see all available qualifiers, see our documentation. Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} w3c / csswg-drafts Public Notifications You must be signed in to change notification settings Fork 719 Star 4.7k Code Issues 3.9k Pull requests 110 Actions Projects 10 Security Uh oh! There was an error while loading. Please reload this page. Insights Additional navigation options Code Issues Pull requests Actions Projects Security Insights [css-display] Should display: contents cause all SVG layout attributes to be ignored? #2502 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. Sign up for GitHub 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 Jump to bottom Closed AmeliaBR opened this issue Apr 5, 2018 · 6 comments Closed [css-display] Should display: contents cause all SVG layout attributes to be ignored? #2502 AmeliaBR opened this issue Apr 5, 2018 · 6 comments Labels Closed Accepted by CSSWG Resolution Commenter Response Pending css-display-3 Current Work SVG Tracked in DoC Comments Copy link Contributor AmeliaBR commented Apr 5, 2018 • edited Loading Uh oh! There was an error while loading. Please reload this page. Previously, it was decided that display: contents "unboxes" SVG's rendered containers (, , ), , and text formatting elements (, , ). In reviewing #2118 (and as discussed on the call recorded in #2118 (comment)), I realized that there wasn't any clear guidance on how display: contents applies to SVG layout attributes that don't have direct CSS counterparts. (At least some of which we would like to eventually map to CSS properties). The relevant attributes: viewBox and preserveAspectRatio on and a that is rendered in a x, y, dx, dy, and rotate on (this x and y don't currently map to the new geometry properties, since the syntax is different) the path for (whether specified as a link or in the new path attribute) and other attributes defining how the text is positioned on the path (In contrast, x, y, width, and height on , , and do all currently map to CSS properties, although with special rules for the interaction of the values on with the values on its immediate shadow child.) My assumption was that these attributes would be cancelled out by display: contents, following the general definition of the contents value: For the purposes of box generation and layout, the element must be treated as if it had been replaced in the element tree by its contents. But there is also the note: As only the box tree is affected, any semantics based on the document tree, such as selector-matching, event handling, and property inheritance, are not affected. [emphasis added] This creates a confusion for x, y, dx, dy, and rotate on which define values that apply to individual characters, and which inherit down through any nested elements to the actual text spans. For example: in this code, the dy value on the overrides the dy value from the parent , so that the words end up above the reference dash (negative offset). If you removed the , the words would be placed below the dash (positive offset): <text y="50%" dy="0 +1em">—<tspan dy="-1em"><a>Where am I?a>tspan>text> Does the dy on the count as a "layout" feature, and disappear if the is made display: contents (allowing the parent value to apply instead)? Or, does it count as a property that is "inherited" through the DOM tree to the individual text nodes, which applies regardless of the number of parent boxes? It's worth mentioning that this "inheritance" doesn't work in the CSS sense of the word. For example, the 0 value on the doesn't inherit into the , because it is consumed by the "—" character. If we ever converted these attributes to CSS properties, they wouldn't be inherited properties, since there would still need to be SVG-specific code to describe how values are assigned to characters. So, on reflection, I think it's best if these attributes are also considered to be "layout" of the element with the attribute, and are ignored if you use display: contents on that element. But either way, it needs to be stated explicitly, for all the attributes. The text was updated successfully, but these errors were encountered: All reactions AmeliaBR added css-display-3 Current Work SVG labels Apr 5, 2018 Copy link Collaborator frivoal commented Apr 5, 2018 White / black listing all the svg attributes in a CSS spec does not sound like the right way forward. It's not very maintainable. We should have categories, and say FOO attributes on display:contents svg elements are suppressed and have no effect, while BAR attributes continue to affect descendants. Based on this discussion, I'm guessing that FOO and BAR are not existing categories, but we should consider creating them. Ideally they should be in the SVG spec(s), so that any time a new attribute is created it is defined which category it belongs to. All reactions Sorry, something went wrong. Uh oh! There was an error while loading. Please reload this page. Copy link Contributor Author AmeliaBR commented Apr 5, 2018 If we go with my final suggestion, and don't add a special case for the text layout attributes, then it would be "any attribute that affects the rendering of child (or shadow-child) elements". Maybe with extra clarification that "presentation attributes no longer apply on this element but follow the normal CSS inheritance rules, including inheritance to anonymous text nodes." So that's another argument in favour of keeping it simple. All reactions Sorry, something went wrong. Uh oh! There was an error while loading. Please reload this page. Copy link Collaborator fantasai commented Apr 5, 2018 I think the rule here should be, if this attribute were mapped to a CSS property, would it inherit or no? If it wouldn't inherit, then it goes away with display: contents. If it would inherit, then it behaves as if it did. Because there's been an ongoing trend of converting SVG attributes to CSS properties, and we wouldn't want to have any difference in behavior as that process continued. (Note that some CSS properties that affect descendant content aren't inherited because we needed to know exactly at which point in the tree they were applied and/or because their effects accumulate. The same is likely to be true of some SVG attributes.) All reactions Sorry, something went wrong. Uh oh! There was an error while loading. Please reload this page. AmeliaBR added a commit that referenced this issue Apr 9, 2018 [css-display] Clarify impact of display: contents on SVG attributes … 573ad1b Addresses #2502 AmeliaBR mentioned this issue Apr 9, 2018 [css-display] textPath and SVG unboxing for display:contents #2118 Closed tabatkins added a commit that referenced this issue Apr 20, 2018 Display contents svg (#2599) … 2cdf747 * [css-display] Describe SVG unboxing with element categories Fixes #2118 * [css-display] Clarify impact of display: contents on SVG attributes Addresses #2502 * [css-display] Add an issue re SVG attributes & display: contents fantasai added the Closed Accepted by CSSWG Resolution label Apr 20, 2018 fantasai closed this as completed Apr 20, 2018 Copy link Contributor Author AmeliaBR commented Apr 20, 2018 If you're closing this issue @fantasai, then you also need to update the spec. 124396a adds an inline issue pointing here as an open issue for discussion about "Is this description clear enough to identify the SVG attributes affected by display: contents?" All reactions Sorry, something went wrong. Uh oh! There was an error while loading. Please reload this page. fergald pushed a commit to fergald/csswg-drafts that referenced this issue May 7, 2018 Display contents svg (w3c#2599) … 7539b4b * [css-display] Describe SVG unboxing with element categories Fixes w3c#2118 * [css-display] Clarify impact of display: contents on SVG attributes Addresses w3c#2502 * [css-display] Add an issue re SVG attributes & display: contents Copy link Collaborator fantasai commented Jun 21, 2018 @AmeliaBR Thanks for the warning. Tightened up the wording a bit, so I think it should be fine unless there are some regular (non-presentation) attributes that ought to inherit but aren't yet defined as being properties. (See #2502 (comment)) Let me know / reopen the issue if you think it needs further adjustment! All reactions Sorry, something went wrong. Uh oh! There was an error while loading. Please reload this page. fantasai added the Commenter Response Pending label Jun 21, 2018 fantasai added a commit that referenced this issue Jun 21, 2018 [css-display-3] Tighten up wording around 'display: contents' and SVG… … 6bc18b7 … attributes. #2502 fantasai added a commit that referenced this issue Jun 21, 2018 [css-display-3] Add some notes about the SVG attributes rule from the… … 1e4dd91 … issue discussion. #2502 Copy link Contributor Author AmeliaBR commented Jun 22, 2018 LGTM. Thanks @fantasai All reactions Sorry, something went wrong. Uh oh! There was an error while loading. Please reload this page. fantasai added the Tracked in DoC label Jul 25, 2018 Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment Assignees No one assigned Labels Closed Accepted by CSSWG Resolution Commenter Response Pending css-display-3 Current Work SVG Tracked in DoC Projects None yet Milestone No milestone Development No branches or pull requests 3 participants You can’t perform that action at this time.
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
Previously, it was decided that display: contents "unboxes" SVG's rendered containers (, , ), , and text formatting elements (, , ).
display: contents
In reviewing #2118 (and as discussed on the call recorded in #2118 (comment)), I realized that there wasn't any clear guidance on how display: contents applies to SVG layout attributes that don't have direct CSS counterparts. (At least some of which we would like to eventually map to CSS properties).
The relevant attributes:
viewBox
preserveAspectRatio
x
y
dx
dy
rotate
path
(In contrast, x, y, width, and height on , , and do all currently map to CSS properties, although with special rules for the interaction of the values on with the values on its immediate shadow child.)
width
height
My assumption was that these attributes would be cancelled out by display: contents, following the general definition of the contents value:
contents
For the purposes of box generation and layout, the element must be treated as if it had been replaced in the element tree by its contents.
But there is also the note:
As only the box tree is affected, any semantics based on the document tree, such as selector-matching, event handling, and property inheritance, are not affected. [emphasis added]
This creates a confusion for x, y, dx, dy, and rotate on which define values that apply to individual characters, and which inherit down through any nested elements to the actual text spans.
For example: in this code, the dy value on the overrides the dy value from the parent , so that the words end up above the reference dash (negative offset). If you removed the , the words would be placed below the dash (positive offset):
<text y="50%" dy="0 +1em">—<tspan dy="-1em"><a>Where am I?a>tspan>text>
Does the dy on the count as a "layout" feature, and disappear if the is made display: contents (allowing the parent value to apply instead)?
Or, does it count as a property that is "inherited" through the DOM tree to the individual text nodes, which applies regardless of the number of parent boxes?
It's worth mentioning that this "inheritance" doesn't work in the CSS sense of the word. For example, the 0 value on the doesn't inherit into the , because it is consumed by the "—" character. If we ever converted these attributes to CSS properties, they wouldn't be inherited properties, since there would still need to be SVG-specific code to describe how values are assigned to characters.
0
So, on reflection, I think it's best if these attributes are also considered to be "layout" of the element with the attribute, and are ignored if you use display: contents on that element.
But either way, it needs to be stated explicitly, for all the attributes.
The text was updated successfully, but these errors were encountered:
White / black listing all the svg attributes in a CSS spec does not sound like the right way forward. It's not very maintainable.
We should have categories, and say FOO attributes on display:contents svg elements are suppressed and have no effect, while BAR attributes continue to affect descendants.
display:contents
Based on this discussion, I'm guessing that FOO and BAR are not existing categories, but we should consider creating them. Ideally they should be in the SVG spec(s), so that any time a new attribute is created it is defined which category it belongs to.
Sorry, something went wrong.
If we go with my final suggestion, and don't add a special case for the text layout attributes, then it would be "any attribute that affects the rendering of child (or shadow-child) elements". Maybe with extra clarification that "presentation attributes no longer apply on this element but follow the normal CSS inheritance rules, including inheritance to anonymous text nodes."
So that's another argument in favour of keeping it simple.
I think the rule here should be, if this attribute were mapped to a CSS property, would it inherit or no? If it wouldn't inherit, then it goes away with display: contents. If it would inherit, then it behaves as if it did. Because there's been an ongoing trend of converting SVG attributes to CSS properties, and we wouldn't want to have any difference in behavior as that process continued.
(Note that some CSS properties that affect descendant content aren't inherited because we needed to know exactly at which point in the tree they were applied and/or because their effects accumulate. The same is likely to be true of some SVG attributes.)
[css-display] Clarify impact of display: contents on SVG attributes
573ad1b
Addresses #2502
Display contents svg (#2599)
2cdf747
* [css-display] Describe SVG unboxing with element categories Fixes #2118 * [css-display] Clarify impact of display: contents on SVG attributes Addresses #2502 * [css-display] Add an issue re SVG attributes & display: contents
If you're closing this issue @fantasai, then you also need to update the spec.
124396a adds an inline issue pointing here as an open issue for discussion about "Is this description clear enough to identify the SVG attributes affected by display: contents?"
Display contents svg (w3c#2599)
7539b4b
* [css-display] Describe SVG unboxing with element categories Fixes w3c#2118 * [css-display] Clarify impact of display: contents on SVG attributes Addresses w3c#2502 * [css-display] Add an issue re SVG attributes & display: contents
@AmeliaBR Thanks for the warning. Tightened up the wording a bit, so I think it should be fine unless there are some regular (non-presentation) attributes that ought to inherit but aren't yet defined as being properties. (See #2502 (comment)) Let me know / reopen the issue if you think it needs further adjustment!
[css-display-3] Tighten up wording around 'display: contents' and SVG…
6bc18b7
… attributes. #2502
[css-display-3] Add some notes about the SVG attributes rule from the…
1e4dd91
… issue discussion. #2502
LGTM. Thanks @fantasai
No branches or pull requests