File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -144,10 +144,26 @@ export class StyleSheet {
144144 // the big drawback is that the css won't be editable in devtools
145145 sheet . insertRule ( rule , sheet . cssRules . length )
146146 } catch ( e ) {
147+ /*
148+ Unrecognized vendor-specific pseudo-selectors like -moz-*
149+ or -webkit-* will throw a SyntaxError when parsed during
150+ the insertRule() call. Since the failing selector(s) target
151+ a different browser, these errors are safe to ignore.
152+
153+ All browsers seem to have slightly different error messages around
154+ this case, making the detection just a little bit more difficult.
155+ SyntaxError errors aren't surfacing frequently.
156+ As long as the rule includes a left curly bracket marking
157+ the beginning of a declaration block AND a vendor-specific
158+ pseudo-selector, we can be almost certain that it is the reason
159+ for the thrown SyntaxError.
160+ */
147161 if (
148162 isDevelopment &&
149- ! / : ( - m o z - p l a c e h o l d e r | - m o z - f o c u s - i n n e r | - m o z - f o c u s r i n g | - m s - i n p u t - p l a c e h o l d e r | - m o z - r e a d - w r i t e | - m o z - r e a d - o n l y | - m s - c l e a r | - m s - e x p a n d | - m s - r e v e a l ) { / . test (
150- rule
163+ ! (
164+ e instanceof SyntaxError &&
165+ / : - ( w e b k i t | m o z | m s | o ) - { / . test ( rule ) &&
166+ rule . indexOf ( '{' ) !== - 1
151167 )
152168 ) {
153169 console . error (
You can’t perform that action at this time.
0 commit comments