Skip to content

Commit

Permalink
fix(lib): resolve RegExp Issue in older versions of Safari (#643)
Browse files Browse the repository at this point in the history
* switch to raw RegExp string instead of object to avoid issues with Safari 9
  • Loading branch information
swftvsn authored and CaerusKaru committed Mar 9, 2018
1 parent 95a6e83 commit 85e8aa2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/core/browser-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export function removeStyles(_document: Document, platformId: Object) {
return () => {
if (isPlatformBrowser(platformId)) {
const elements = Array.from(_document.querySelectorAll(`[class*=${CLASS_NAME}]`));
const classRegex = new RegExp(/\bflex-layout-.+?\b/, 'g');

// RegExp constructor should only be used if passing a variable to the constructor.
// When using static regular expression it is more performant to use reg exp literal.
// This is also needed to provide Safari 9 compatibility, please see
// https://stackoverflow.com/questions/37919802 for more discussion.
const classRegex = /\bflex-layout-.+?\b/g;
elements.forEach(el => {
el.classList.contains(`${CLASS_NAME}ssr`) && el.parentNode ?
el.parentNode.removeChild(el) : el.className.replace(classRegex, '');
Expand Down

0 comments on commit 85e8aa2

Please sign in to comment.