Skip to content

Commit

Permalink
Add support for \!important priority in CSS declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
openhands-agent committed Dec 6, 2024
1 parent bf180ef commit 55747a7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/devtools/client/inspector/computed/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,15 @@ export async function createComputedProperties(
cachedParsedProperties.set(combinedNameValue, parsedValue);
}


selectors.push({
value: property.value,
parsedValue,
selector,
stylesheet,
stylesheetURL,
overridden: !!property.overridden,
priority: property.priority,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default function ComputedProperty(props: ComputedPropertyProps) {
<div className="matchedselectors">
{isExpanded
? property.selectors.map((selector, index) => (
// Reproduction step Repro:ComputedProperty:
<MatchedSelector key={index} selector={selector} />
))
: null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ export default function MatchedSelector(props: MatchedSelectorProps) {
<span dir="ltr" className="rule-text theme-fg-color3">
<div className="fix-get-selection">{selector.selector}</div>
<div className="fix-get-selection computed-other-property-value theme-fg-color1">

<DeclarationValue
colorSpanClassName="computed-color"
colorSwatchClassName="computed-colorswatch"
fontFamilySpanClassName="computed-font-family"
values={selector.parsedValue}
priority={selector.priority}
/>
</div>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ interface DeclarationValueProps {
colorSwatchClassName: string;
fontFamilySpanClassName: string;
values: (string | Record<string, string>)[];
priority?: string;
}

class DeclarationValue extends React.PureComponent<DeclarationValueProps> {
render() {
return this.props.values.map(v => {

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

return value;
});

// Add the !important suffix if needed
if (this.props.priority === "important") {
renderedValues.push(" !important");
}

return renderedValues;
}
}

Expand Down

0 comments on commit 55747a7

Please sign in to comment.