Open Bug 2088462 Opened 14 days ago Updated 13 days ago

color swatch not displayed for var()/attr() when var/attribute 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, there should be a gold color swatch

Actual results

There isn't one


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

output-parser.js #onCloseParenthesisForVar takes the variable name from the first Ident part. With var(ident("--x-" sibling-index()), lime) the name is a group of parts that all map to one AGGREGATED_TOKEN_TYPE entry, so the loop reaches the comma first, varNameIndex stays null, and the function returns before getVariableData is called. That means nothing is substituted and no gold swatch is drawn. #onCloseParenthesisForAttr has the same first-Ident lookup at #880-915.

Fix: Add an ident branch to #onCloseParenthesis that resolves the name from its arguments. It should unquote strings, String() numeric children such as sibling-index(), and leave the name unset if any argument is unresolved, such as random() or attr(). Then have the var and attr handlers accept that aggregated part as the name and wrap all of its parts, not just the first, in the name node. Cover this with a case in testParseVariable in browser_outputparser.js, which also fixes the fallback marking in bug 2088461 and the jump button in bug 2088464.

Suggested severity: S4. Only the color swatch is missing, the declaration still applies correctly, and it only appears once ident() ships behind its Nightly pref.


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.