-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fresh regex every time extractCritical is called #177
Conversation
Codecov Report
@@ Coverage Diff @@
## master #177 +/- ##
==========================================
+ Coverage 89.11% 89.13% +0.02%
==========================================
Files 22 22
Lines 845 847 +2
Branches 219 219
==========================================
+ Hits 753 755 +2
Misses 70 70
Partials 22 22
Continue to review full report at Codecov.
|
src/server.js
Outdated
@@ -16,6 +14,8 @@ export { | |||
export function extractCritical (html) { | |||
// parse out ids from html | |||
// reconstruct css/rules/cache to pass | |||
const RGX = /css(?:[a-zA-Z0-9-]*)-([a-zA-Z0-9]+)/gm | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to do RGX.lastIndex = 0
after the while loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nyah, it gets GCed and lost anyway after it's done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about its usage here though. https://github.com/tkh44/emotion/pull/177/files/737e2b32325571d1dec2da461222aa995981e091#diff-e6a5b42b2f7a26c840607370aed5301aR29
What: Use a fresh regex every time
extractCritical
is calledWhy: regexes are stateful, and the current method would break critical css extraction unexpectedly because of previous runs
How: the regex declaration was brought inside the function
Checklist: