Skip to content

Conversation

@connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Sep 8, 2022

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 introduce ExecutionContext.serializeDependencies and someFn.dependencies to do the same. we set toString

@connorjclark connorjclark requested a review from a team as a code owner September 8, 2022 21:17
@connorjclark connorjclark requested review from adamraine and removed request for a team September 8, 2022 21:17
Comment on lines 542 to 548
getNodeDetails.dependencies = [
getNodePath,
getNodeSelector,
getBoundingClientRect,
getOuterHTMLSnippet,
getNodeLabel,
];
Copy link
Contributor

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.

Copy link
Collaborator Author

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 :)

Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants