-
Notifications
You must be signed in to change notification settings - Fork 9.5k
core(page-functions): remove all *String
exports
#14374
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
Conversation
core/lib/page-functions.js
Outdated
getNodeDetails.dependencies = [ | ||
getNodePath, | ||
getNodeSelector, | ||
getBoundingClientRect, | ||
getOuterHTMLSnippet, | ||
getNodeLabel, | ||
]; |
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 if we just override the toString
function on getNodeDetails
to include the deps? It's the only place we would need to do it.
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.
Tacking on a property to Function is iffy enough, I draw the line at overriding Object.prototype.toString
:)
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.
In the realm of js hackery, though, it does seem much more idiomatic to override a function's toString
to customize what happens when it's serialized to a string than to have a magic property for it. That's toString
's literal purpose.
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.
Tacking on a property to Function is iffy enough, I draw the line at overriding Object.prototype.toString
I wasn't suggesting overriding Object.prototype.toString
. I was suggesting we do getNodeDetails.toString = () => {...}
or something
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 know, s/override/shadow
This reverts commit 1725988.
All but one of these can be dropped just by using their function directly.
getNodeDetails
is special because it has a number of other page-functions that must be included to work, which was solved by making its*String
export wrap those deps (so callers wouldn't have to remember to). Instead,I introducewe setExecutionContext.serializeDependencies
andsomeFn.dependencies
to do the same.toString