-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
[core] Simplify/Cleanup StyleManager
#959
Conversation
One comment: do you know if we need to shim the And do we also want to add Grim deprecate messages for those functions, on the off-chance that something somewhere uses it? |
@Spiker985 I'm rather confident that those functions were only ever used internally. I mean Searching the entire repository brings a total of two hits for So I don't think we have anything to worry about tbh |
Co-authored-by: DeeDeeG <DeeDeeG@users.noreply.github.com>
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.
I read through the src/style-manager.js
, since trawling through the diff of code I was unfamiliar with was taking a bit, and reading the file, regardless of how it may have looked before, I found the file rather readable as-updated by this PR.
Admittedly not being 1000% thorough, and I can't speak to how it was before this PR really, but what I saw so far looked rather readable.
Thanks for the patience waiting for a review... Looks Good To Me ™️ ! 👍
P.S. this has specs, which are updated form the PR, bonus points. 👍 CI is passing.
Thanks @DeeDeeG appreciate you taking a look! Do we wanna wait for the new set of specs to pass or do we feel confident with the last run prior to your suggestion? |
Either way is fine with me! (Leaning slightly toward merge without waiting, since it's Release day and the change was intended to be pretty trivial. Hopefully I didn't put a fatal typo in my very brief code suggestion, but if I did that's my fault and I'll fix it some way.) EDIT: For the record, the ❌ above reflects cancelled tasks, not failed ones. (At least as of when I'm typing this.) I suppose GitHub Actions figured there'd be no point in continuing to run specs on a PR that already merged, canceled some tasks, and those show as a red "x" status. |
See also this last-minute fix: 31d7d84 Commit with the fix is being included in the version bump PR for 1.116.0: #977. (As it was explained to me: This PR had an old function name left in place, instead of the new name, which broke something only specs need/use. Unclear why it passed CI in the first place, only to then start failing on any subsequent test runs. (????) But is fixed in that commit, so it seems so far. Editor tests are passing for that branch with the fix. 👍) |
While investigating #930 I realized how complicated and unintuitive the
StyleManager
code was in the locations I needed to inspect.This is mostly due to the fact that significant portions of the logic was doubled up, but then required safety to not overlap itself.
So I've gone ahead and applied some refactoring and simplification of the code to make it easier to read, and ideally allow a follow up PR that resolves the issue mentioned above.
Which to be clear, this PR does not resolve the issue mentioned above. Only cleans up the code to make that easier, and of course try to make things more readable.
In this PR:
upgradeDeprecatedSelectorsForStyleSheet
andupgradeDeprecatedMathUsageForStyleSheet
have been removed in favor of the functionupgradeStyleSheet
which accepts a callback parameter of a function to actually call, allowing that single function to do what the both of these did.addStyleSheet
I've gone ahead and removed all duplicated logic, instead opting for two variablestextContent
anddeprecationMessages
to track the current state of thestyleElement.textContent
andthis.deprecationsBySourcePath
values respectively.But otherwise this PR should result in zero change in actual behavior, only making things hopefully more readable.