Skip to content
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

[bug3023] Expressions refactoring #32

Closed
wants to merge 3 commits into from
Closed

[bug3023] Expressions refactoring #32

wants to merge 3 commits into from

Conversation

kachurun
Copy link
Collaborator

No description provided.

@kachurun kachurun added the invalid This doesn't seem right label Oct 20, 2024
@kachurun kachurun added enhancement New feature or request and removed invalid This doesn't seem right labels Oct 21, 2024
@kachurun kachurun force-pushed the bug3023 branch 2 times, most recently from 00c4986 to 583a1a4 Compare October 21, 2024 04:23
@GianlucaGuarini
Copy link
Member

Thank you @kachurun for this PR but this code will reduce massively the riot performance since the value dirty checks were partially removed. I am working on the same issue and I might have found a solution to it so for now let's close this PR.
Thank you for the time you spent refactoring it, please in future add a bit more info about your work and split the changes into smaller PRs. 🙏

Comment on lines -66 to -69
expression.node,
expression,
value,
expression.value,
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 don't see any reason to pass 4 arguments when one of them already contains everything you need

Comment on lines -18 to -24
// hopefully a pure function
this.value = this.evaluate(scope)

// IO() DOM updates
apply(this, this.value)

return this
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduce code duplication

Comment on lines +30 to 35
// ref attributes should be called only once during mount
if (this.name === REF_ATTRIBUTE && !this.value) {
value(this.node)
this.value = value
return this
}
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 moved it here so that the mount/unmount logic is in one place. Removed any ref processing from attribute expressions.
But in any case it looks ugly here, I would prefer a dedicated expression type for ref.

// otherwise we can try to render it
return typeof value === 'undefined' || value === null
function handleSpreadAttributes(node, value, oldValue) {
const newKeys = Object.keys(value || [])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the double calculation of the object keys

@@ -1,10 +1,8 @@
import { isNil } from '@riotjs/util/checks'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This thing is not used anywhere in riot except this file, and it's too complicated because there is no difference between v=== null|| v=== undefined and just `v== null'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants