Skip to content
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

Display matched selector priority #10609

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/devtools/client/inspector/computed/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,14 @@ export async function createComputedProperties(
const combinedNameValue = `${name}:${property.value}`;
let parsedValue = cachedParsedProperties.get(combinedNameValue)!;
if (!parsedValue) {
parsedValue = outputParser.parseCssProperty(name, property.value);
parsedValue = outputParser.parseCssProperty(name, value);
cachedParsedProperties.set(combinedNameValue, parsedValue);
}

selectors.push({
value: property.value,
parsedValue,
priority: property.priority,
selector,
stylesheet,
stylesheetURL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function MatchedSelector(props: MatchedSelectorProps) {
colorSpanClassName="computed-color"
colorSwatchClassName="computed-colorswatch"
fontFamilySpanClassName="computed-font-family"
priority={selector.priority}
values={selector.parsedValue}
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/devtools/client/inspector/computed/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface MatchedSelectorState {
selector: string;
value: string;
parsedValue: any[];
priority: string;
overridden: boolean;
stylesheet: string;
stylesheetURL: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ interface DeclarationValueProps {
colorSpanClassName: string;
colorSwatchClassName: string;
fontFamilySpanClassName: string;
priority?: string;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there places where we'd like to render this without the priority? Chrome doesn't render it in its Computed tab

values: (string | Record<string, string>)[];
}

class DeclarationValue extends React.PureComponent<DeclarationValueProps> {
render() {
return this.props.values.map(v => {
const values = this.props.values.map(v => {
if (typeof v === "string") {
return v;
}
Expand Down Expand Up @@ -46,6 +47,13 @@ class DeclarationValue extends React.PureComponent<DeclarationValueProps> {

return value;
});

return (
<>
{values}
{this.props.priority ? ` !${this.props.priority}` : null}
</>
);
}
}

Expand Down
Loading