Commit ec87bae
committed
fix: using Regular Expressions on Firefox
DOM Testing Library uses instanceof to check whether a query is passed a
RegExp, a Function or a string arg. For some reason on Firefox when a
RegExp is passed to a query the `arg instanceof RegExp` check is always
false, resulting in RegExp arguments being treated like a string. It
appears that this is because the RegExp that is created in executeQuery
is not the same class as that used in the instanceof check in DTL.
I'm not sure exactly what could be causing it, it's possible that
this is due to a polyfill or how we are adding DTL to the page, or
something completely different.
Assigning the RegExp that is in scope in executeQuery to window.RegExp
seems to fix the problem, presumably because it overrides whatever
modified RegExp class was added by the UMD script.1 parent 40e64b0 commit ec87bae
1 file changed
+3
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
| |||
0 commit comments