Skip to content

Conversation

@rschristian
Copy link
Member

Targetting v11 as it's breaking.

I'd like to kill off this interface from core, only offering it as any through compat going forward. It's fundamentally a bad interface and no one should be using it:

  1. Using it allows for nonsensical props to be set. This is most often utilized by component libs that do something like props: AllHTMLAttributes<HTMLDivElement>, I'm guessing expecting the HTMLDivElement generic to somehow narrow the type but it doesn't work like that. This allows the user to set (say) referrerPolicy despite that doing nothing on the target <div> element.

  2. There's obvious & unavoidable conflicts in the interface members, such as InputHTMLAttributes.type vs AnchorHTMLAttributes.type -- which type do we expose here? Common denominator string? any?

  3. It's a pain to maintain. Theoretically every single prop/attr needs to be added to that interface and we can't simply extend our per-element interfaces as they're not static (or won't be w/ refactor: Restrict aria roles by element type #4607). Every type alteration would need to be added in two separate places, else, the types start getting a bit flakey for users.

We have per-element types now, and while they're probably not perfect, users should be reaching for them instead as they're much, much more useful.

JoviDeCroock and others added 30 commits February 27, 2025 08:09
* Revert assign and avoid repeating indexed access

* Check parentNode instead

* Use flag

* Remove type

* Remove todo file
* Forward ref by default

* Optimizations
* Move `defaultProps` into `preact/compat`

This will be handled in `options.vnode` for function/class components.
This hook gets called for every invocation of `jsx`/`createElement` and
`cloneElement`.

* Try it

* refactor: This is horrific but seems to work? (#4662)

---------

Co-authored-by: Ryan Christian <33403762+rschristian@users.noreply.github.com>
* Remove unused imports

* Comment denoted hydration

* Make it work

* Golfies
* Remove unused imports

* refactor: Switch to Object.is for hook args

* refactor: Copy to `useReducer` & store `Object` accessor

* test: Add tests for `useEffect` & `useState` w/ `NaN`

Co-authored-by: jayrobin <james.michael.robinson@googlemail.com>

---------

Co-authored-by: jdecroock <decroockjovi@gmail.com>
Co-authored-by: jayrobin <james.michael.robinson@googlemail.com>
This reverts commit 6b8bfa2.
* refactor: Switch to `package.json#exports.module`, drop `.min` builds, &  use `.mjs` exclusively

* chore: Remove leftover CJS shell

* test: Fix export for karma

* fix: coverage not generated in minify tests

---------

Co-authored-by: Marvin Hagemeister <hello@marvinh.dev>
* Remove automatic px suffix

* Remove from jsx-runtime
Copy link
Member

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

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

I'm atm very hesitant on this one due to people that might be relying on this

@rschristian
Copy link
Member Author

rschristian commented Feb 27, 2025

They shouldn't be is the point I was trying to make, it doesn't reasonably constrain the types.

There's no situation that I can see in which every single known attribute/property is valid -- it's always a subset.

Happy to let this sit but this (or reverting #4706, which I didn't foresee this issue with it) blocks #4607.

@rschristian
Copy link
Member Author

Upon more thought, let's not. The value is unclear & it's a pain to maintain correctly, but letting it sit isn't much of an issue. I'll revert part of #4706 instead.

@rschristian rschristian deleted the types/remove-all-html-attributes branch March 13, 2025 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants