Open Bug 2088464 Opened 14 days ago Updated 13 days ago

no "jump to" definition button in var() when var name is built from an ident() function

Categories

(DevTools :: Inspector: Rules, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: nchevobbe, Unassigned)

References

(Blocks 1 open bug)

Details

Steps to reproduce

  1. With support for ident() (see patch in Bug 2088337)
  2. Navigate to data:text/html;charset=utf-8,<!doctype html><style>span {%0A%20 font-size: 48px;%0A%20 --x-1: gold;%0A%20 --x-2: tomato;%0A%20 color: var(ident("--x-" sibling-index())%2C lime);%0A}</style><body><span>A</span>%0A<span>B</span>%0A<span>C</span></body>
  3. Inspect A

Expected results

In the color declaration, we should have a "jump to" button after the ident() that would jump to --x-1 when clicked

Actual results

There is no jump button


Note that this might not be doable when the ident uses random()/random-item() (at least not in our current setup)

#onCloseParenthesisForVar in output-parser.js takes the first Ident token before the comma as the variable name. By then ident("--x-" sibling-index()) has already been folded into one aggregated part by #onCloseParenthesis, so no name is found and the function returns at #1740 before the jump button at #1818 is created.

Fix: Add an ident branch to #onCloseParenthesis (#553-581) that resolves the name when every argument is a string (token.value), an ident, an integer, or sibling-index()/sibling-count() with a substitutedText, and leaves it unresolved for random(), attr() and anything else. #onCloseParenthesisForVar then uses the resolved name and wraps every part that shares the aggregated token in the name node, as the fallback wrapping already does. Also store the resolved name in a data attribute for the variable tooltip, because utils.js and tooltips-overlay.js require the node text to start with --, and teach getCSSVariables (utils.js#349) this form so --x-1 is not flagged as unused. Add cases to testParseVariable in browser_outputparser.js and to browser_rules_variables-jump-to-definition.js. Bugs 2088461 and 2088462 need the same resolved name, so the resolver should land here first.

Suggested severity: S4. This is a missing convenience link for a CSS function that is not yet shipped outside Nightly, and the variable's declaration is still visible and findable in the same rule.


If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
If you want to categorize your feedback you can add one of the following tags: ai-triage-{wrong-file, wrong-cause, hallucination, out-of-scope, not-a-bug, wrong-fix, shallow-fix, wrong-severity}.

Needinfo hackbot@mozilla.tld to have a patch generated for this bug, include any questions or directions as needed in your comment.

Severity: -- → S3
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.