Skip to content

Attribute Ordering #43

@rturnq

Description

@rturnq

I've been playing around with Solid and came across an issue I found interesting. There is at least one case where an HTML element has an attribute with a dependency on another one of its attributes, which means that the order of their application becomes important.

I've documented some examples here https://codesandbox.io/s/attribute-order-example-pmdqh

The range input <input type="range" /> has a min and max attribute which are taken into account when setting the value. This makes sense, you have to clamp the value set in order to keep it in range.

Essentially, if you apply the value before min and max, you may (depending on the numbers used) get a different outcome than applying the min and max first. This is easy enough for an author to fix by simply changing the ordering in their JSX; however, this brings up a few questions

  • Does the DOM Expressions library guarantee ordering of application at runtime based on the ordering found is the JSX?
  • Is this something the user should have to be aware of? I found the issue trying to create the same simple app in React, Vue and Solid - the others appear to prevent the issue.
  • If a user's code sets some state that updates all of these attributes at the same time (ie setState({ min, max, value });) could this cause a problem? What determines the order they are applied?

I'm not sure what the answers are but it seems like the best solution would be to uncover all of these attribute dependencies (maybe other elements have them too) and take them into account when applying updates, possibly rearranging the calls so the application author and end user have a consistent outcome.

I really like this project and I'm blown away that it seems to have everything I love about React (JSX, functional components, hooks) in such a tiny and speedy library. Good work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions