mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-29 16:57:00 +08:00
DevTools: Improper function call in Styles pane
A bug in the Styles pane exists due to un-followed typing within the _setActiveProperty function. The line previous to the expression in question goes through treeElement.property, which is a StylePropertyTreeElement. Its property `ownerStyle` returns an SDK.CSSStyleDeclaration. We can see that SDK.CSSStyleDeclaration is initialized with a property `parentRule` of type SDK.CSSRule, which is the inferred type of `rule` in the outcome of the line in question. However, SDK.CSSRule does not contain a member function called `selectorText()`; only SDK.CSSStyleRule does. Ostensibly it's possible that this is of type CSSKeyframesRule or CSSKeyframeRule, and neither of these contains meaningful definitions of something that matches a "selector," so it isn't really practically possible to address via polymorphism. This corrects the value-check and only calls the function if the rule in question is of type SDK.CSSStyleRule. Change-Id: I960e2b49ce9734134b55007149a39a97861739dd Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1872447 Reviewed-by: Lorne Mitchell <lomitch@microsoft.com> Commit-Queue: Lorne Mitchell <lomitch@microsoft.com>
This commit is contained in:
@@ -432,7 +432,7 @@ Elements.StylesSidebarPane = class extends Elements.ElementsSidebarPane {
|
||||
}
|
||||
|
||||
const rule = treeElement.property.ownerStyle.parentRule;
|
||||
const selectorList = rule ? rule.selectorText() : undefined;
|
||||
const selectorList = (rule instanceof SDK.CSSStyleRule) ? rule.selectorText() : undefined;
|
||||
for (const mode of ['padding', 'border', 'margin']) {
|
||||
if (!treeElement.name.startsWith(mode)) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user