Giter VIP home page Giter VIP logo

Comments (9)

rschristian avatar rschristian commented on August 25, 2024 1

@rejhgadellaa have you checked the latest version? I believe that was a bug that was corrected.

Edit: Never mind, hasn't been released yet. Fixed in #4393 though

from preact.

rschristian avatar rschristian commented on August 25, 2024

Answer: it depends, sometimes Preact sets the .foo property, sometimes Preact sets the foo attribute. The user has no control over this.

While I don't disagree with the premise/request, and have written up minor forks/patches that add this, there are quite defined rules. It's not random or a guess: if the provided label has a DOM property, and isn't from a small list of excluded labels, it gets set as a property, else, attr.

Preact (and other UI libs) aren't "guessing" at what others expect; they work with the DOM as they see fit. It's up to the individual devs to reconcile the expectations of different pieces of software. More control here would absolutely help devs reconcile those expectations, but I just want to make it clear that it isn't really a project goal to "guess correctly" as you put it.

from preact.

trusktr avatar trusktr commented on August 25, 2024

It's not random or a guess: if the provided label has a DOM property, and isn't from a small list of excluded labels, it gets set as a property, else, attr.

Perhaps "heuristic" or "rules" are better terms. To re-express with those words, no heuristic or rule can satisfy all scenarios because all scenarios can only be users picking which to use.

from preact.

rschristian avatar rschristian commented on August 25, 2024

Not quite what I meant, no. We largely set what we set, we're not looking to satisfy any scenarios beyond "works with DOM APIs correctly". Anything beyond that is a non-goal of the project really, something for users to address. It's not a concern of the project if it doesn't enable a CSS selector, for example.

Not having great tools for users to address these issues is, however, a valid issue for the project, if that makes sense.

Minor (perhaps frivolous) semantics, I know, but I want to clarify project goals.

from preact.

trusktr avatar trusktr commented on August 25, 2024

I'm not sure what's the debate. In my mind it's a valid request (and likely project goal) to be able to control DOM elements with a DOM framework like Preact (wanting to set an attribute to use for CSS selecting is but one of many reasons), but of course that's up to each framework.

I changed the issue template to feature request (accidentally chose bug first).

from preact.

rejhgadellaa avatar rejhgadellaa commented on August 25, 2024

I recently ran into the popover property not accepting boolean values, but the attribute can be a boolean (it will then default to auto). So this:

<menu popover />

Will actually try to set Element.popover = true (which is an error)

You have to write:

<menu popover="auto" />

Not a big problem, but annoying 😅

from preact.

rschristian avatar rschristian commented on August 25, 2024

@trusktr I'm saying the comments of "It is not possible for Preact to always guess correctly which of the above cases the user will want" and "no heuristic or rule can satisfy all scenarios" aren't really relevant as it's not, nor was it ever, a project goal to do that. That was always on the user's end of things.

I just want to make that clear as the inability to "guess which cases the users will want" is not in itself a problem or a valid issue, as we never made any attempt at all to guess what a user could prefer in sone scenario. Lack of tools for the user to set things how they want, however, is absolutely a valid issue.

It's somewhat important framing, as it's confusing fundamental project goals, but I digress.

from preact.

rejhgadellaa avatar rejhgadellaa commented on August 25, 2024

@rschristian oh sweet, I actually thought this was "working as intended", and maybe even more of an issue of the spec where the property and attribute don't accept the same argument types. Thanks!

from preact.

hesxenon avatar hesxenon commented on August 25, 2024

why not check the static observedAttributes? If my custom element is interested in e.g. disabled I must add "disabled" to the observedAttributes property anyway - which should sufficiently state that I am indeed interested in the content attribute and preact should not just drop that

from preact.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.