-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Add describe() and describeElement() #4654
Conversation
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.
Hey Luis, this is in great shape! I've asked some minor questions and made some suggestions in the review. The one big thing to do is to write some unit tests for this new functionality. I'll look for the appropriate guides before we meet today—it's been a while since I've done this, so we can look it over together.
Hi Kate! No worries! Just added the test cases and "!" "?" exceptions in the regex. 😸 |
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.
🎉 Let mostly code readability comments on this. Main things to look out for:
- writing out variable and function names for readability
- instead of checking
(blah === null)
or(blah === false)
, you can write(!blah)
- internal helper functions don't need to be attached to p5.prototype
also wondering if performance-wise it's useful to store any of the DOM elements instead of needing to use getElementByID
@lmccart thx for the feedback! I've made all of the suggested changes! 😺 @kjhollen I still got a couple of new issues with tests —that came up with the new changes — to fix before merge, will comment on them in case you get a chance to look at them. I should be able to work through them before our next meeting. |
Hey @lm-n! So I took a quick look at the tests ( I hope you don't mind 😅 ). That's probably because even though the If we have a new internal function as p5.prototype._clearDummy = function() {
dummy = { fallbackElements: {}, labelElements: {} };
} and call this in Also, I didn't see the need for using |
Thanks @kjhollen and @akshay-99 ❤️ ❤️ ❤️ ! Akshay you were right! We had some problems with dummy beyond what you identified. It should work now 👯♀️ 👯♂️ ! |
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.
comments are a great addition! I think the dummy DOM is a little different than I'd expected, but is in good shape (I think I just thought there would be a variable attached to the p5 instance for the description DOM nodes). More context in comment inline.
if (!dummy[cnvId + labelContainer]) { | ||
|
||
//clear dummy | ||
p5.prototype._clearDummy = function() { |
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'm curious why this method is attached to the prototype but not the fallback elements or label elements. Wondering if it makes sense for fallbackElements and labelElements to be attached to a p5 instance? (I recall that this got added to fix the tests, am wondering if attaching to the instance would also fix that or if there are other possible advantages)
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 built everything this morning to double check that tests are passing and all seems to be in good shape! I think we can merge this as-is.
@lm-n and I chatted yesterday and thought there might be a way to move the "dummy" object into the p5 instance, to simplify some of the element lookup & tests. This part of the code is also used in #4703, so we thought that work could continue there—and that it makes sense to merge this patch so that the code doesn't need to be updated in 2 different branches. if that sounds ok to you @lmccart I'll merge this later today!
hey @lm-n I was double-checking this with a merge from
Then some of the examples (in p5.Font.js, p5.Image.js, vertex.js, image.js, pixels.js, dom.js, files.js, and p5.Graphics.js) seem to have trouble with the linter (prettier) in the task I'm not sure if it's safe to merge so I'm going to hold off for now! But knowing that you've got newer work ready to go / review, I'm hoping we can still get this resolved quickly. |
@kjhollen all good to merge by me once these last little issues get resolved |
ok, I realized that I had locally run
which updated my package-lock.json and package.json files to versions beyond what the project expected, and caused the issues I wrote about yesterday. I figured this out by doing a clean checkout of the main branch, where everything worked ok until I ran Anyway, it was a clean build once I figured this out and all tests pass, so I'm going to merge! Congrats @lm-n! 🎉 |
Changes:
PR Checklist
npm run lint
passesPending: