-
Notifications
You must be signed in to change notification settings - Fork 22.8k
abs()
function: update parameter and return value
#41005
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,17 +17,23 @@ width: abs(20% - 100px); | |||||||||
|
||||||||||
### Parameters | ||||||||||
|
||||||||||
The `abs(x)` function accepts only one value as its parameter. | ||||||||||
The `abs()` function's syntax is as follows: | ||||||||||
|
||||||||||
- `x` | ||||||||||
- : A calculation which resolves to a number. | ||||||||||
```plain | ||||||||||
abs( <calc-sum>) | ||||||||||
``` | ||||||||||
|
||||||||||
The parameter is: | ||||||||||
|
||||||||||
Comment on lines
+20
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the new convention? Because this would go against all other references that use "Parameters", which all generally only include a DL. Our page template: https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Page_structures/Page_types/CSS_function_page_template#parameters also does not include this part. This should probably go into the syntax box above:
(In other news we need to remove I'm not against the convention you are proposing here, but we should document it in the page template here, which may also help resolve #40500, alternatively we should consider #40500 a prerequisite, because if we settled on the approach I proposed above, then we can simply remove all this introduction. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also don't think we should add syntax to the "Parameters" section. The first and most obvious reason is that that would make this section inconsistent with our template for CSS functions. Another is that this syntax is too simplistic compared to what we show in Formal syntax, where each value expands into more further underlying expressions - this could become a problem if we try to apply this approach to other function pages. anchor() is probably not the best example to follow for this. asin() and clamp() are better aligned with the template (minus the "Syntax" block). As for the "Syntax" block, although the template says:
Currently this is pretty inconsistent across our function pages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A function is not a property value. Writing |
||||||||||
- `<calc-sum>` | ||||||||||
- : An expression, or calculation, which resolves to a {{cssxref("number")}}, {{cssxref("length")}}, {{cssxref("percentage")}} or a {{cssxref("calc-keyword"). | ||||||||||
Comment on lines
+28
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as per the Formal syntax, length should be dimension?
Suggested change
|
||||||||||
|
||||||||||
### Return value | ||||||||||
|
||||||||||
The absolute value of `x`. | ||||||||||
The absolute value of `<calc-sum>`. | ||||||||||
|
||||||||||
- if `x`'s numeric value is positive or `0⁺`, return `x`. | ||||||||||
- Otherwise, returns `-1 * x`. | ||||||||||
- if `<calc-sum>`'s numeric value is positive or `0⁺`, return `<calc-sum>`. | ||||||||||
- Otherwise, returns `-1 * <calc-sum>`. | ||||||||||
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
## Formal syntax | ||||||||||
|
||||||||||
|
@@ -58,7 +64,7 @@ div { | |||||||||
|
||||||||||
### Backwards compatible fallback | ||||||||||
|
||||||||||
In older browsers that lack the support for CSS `abs()` function, you can use the CSS {{CSSxRef("max")}} function to achieve the same result, as shown below: | ||||||||||
In browsers that lack support for CSS `abs()` function, you can use the CSS {{CSSxRef("max")}} function to achieve the same result: | ||||||||||
|
||||||||||
```css | ||||||||||
p { | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should keep the fact that it takes only one parameter