Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 85e8aa2

Browse files
swftvsnCaerusKaru
authored andcommitted
fix(lib): resolve RegExp Issue in older versions of Safari (#643)
* switch to raw RegExp string instead of object to avoid issues with Safari 9
1 parent 95a6e83 commit 85e8aa2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/lib/core/browser-provider.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ export function removeStyles(_document: Document, platformId: Object) {
1717
return () => {
1818
if (isPlatformBrowser(platformId)) {
1919
const elements = Array.from(_document.querySelectorAll(`[class*=${CLASS_NAME}]`));
20-
const classRegex = new RegExp(/\bflex-layout-.+?\b/, 'g');
20+
21+
// RegExp constructor should only be used if passing a variable to the constructor.
22+
// When using static regular expression it is more performant to use reg exp literal.
23+
// This is also needed to provide Safari 9 compatibility, please see
24+
// https://stackoverflow.com/questions/37919802 for more discussion.
25+
const classRegex = /\bflex-layout-.+?\b/g;
2126
elements.forEach(el => {
2227
el.classList.contains(`${CLASS_NAME}ssr`) && el.parentNode ?
2328
el.parentNode.removeChild(el) : el.className.replace(classRegex, '');

0 commit comments

Comments
 (0)