File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed
packages/react-devtools-shared/src/backend/StyleX Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,10 @@ function crawlObjectProperties(
6767 // Special case; this key is the name of the style's source/file/module.
6868 sources . add ( key ) ;
6969 } else {
70- resolvedStyles [ key ] = getPropertyValueForStyleName ( value ) ;
70+ const propertyValue = getPropertyValueForStyleName ( value ) ;
71+ if ( propertyValue != null ) {
72+ resolvedStyles [ key ] = propertyValue ;
73+ }
7174 }
7275 } else {
7376 const nestedStyle = { } ;
@@ -90,13 +93,19 @@ function getPropertyValueForStyleName(styleName: string): string | null {
9093 const styleSheet = ( ( document . styleSheets [
9194 styleSheetIndex
9295 ] : any ) : CSSStyleSheet ) ;
93- // $FlowFixMe Flow doesn't konw about these properties
94- const rules = styleSheet . rules || styleSheet . cssRules ;
95- // $FlowFixMe `rules` is mixed
96+ let rules : CSSRuleList | null = null ;
97+ // this might throw if CORS rules are enforced https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface
98+ try {
99+ rules = styleSheet . cssRules ;
100+ } catch ( _e ) {
101+ continue ;
102+ }
103+
96104 for ( let ruleIndex = 0 ; ruleIndex < rules . length ; ruleIndex ++ ) {
97- // $FlowFixMe `rules` is mixed
98- const rule = rules [ ruleIndex ] ;
99- // $FlowFixMe Flow doesn't konw about these properties
105+ if ( ! ( rules [ ruleIndex ] instanceof CSSStyleRule ) ) {
106+ continue ;
107+ }
108+ const rule = ( ( rules [ ruleIndex ] : any ) : CSSStyleRule ) ;
100109 const { cssText, selectorText, style} = rule ;
101110
102111 if ( selectorText != null ) {
You can’t perform that action at this time.
0 commit comments