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

[Suggestion] Global state attribute #6953

Closed
OmidHekayati opened this issue Aug 11, 2021 · 3 comments
Closed

[Suggestion] Global state attribute #6953

OmidHekayati opened this issue Aug 11, 2021 · 3 comments

Comments

@OmidHekayati
Copy link

I suggest adding a new global state attribute to the HTMLElement interface! It can have one or more values at the same time! e.g. state="disabled,checked"

Goals

  • Improve HTML spec in semantic aspect!
  • Standard all elements states under one attribute. Exiting state attributes usually as boolean attributes and even some hidden attributes that use by everyone like pseudo-classes in CSS!
    For example, we need an open boolean state attribute in <details> also in <dialog> and even non-standard tag like <popup> (I don't think popup tag is good enough to be in the HTML standard!) and it can standard under state="" attribute!
  • Have global and standard onStateChange() listener to check if any state changed to an element!
  • Solve many problems like those discussed at [Suggestion] dialog element #6730 and Dialog should be better-behaved on misuse, probably #5802 and many other problems that lead to not have the state attribute standard!

Suggested state value

Below list just examples not include all states! Some state values may sound unnecessary but for example, they use in touch screens and are useful in many cases!

const (
	ElementStateUnset
	ElementStateNormal
	ElementStateError

	ElementStateOpening
	ElementStateOpened
	ElementStateClosing
	ElementStateClosed

	ElementStateToggling
	ElementStatePushed

	// User actions states
	ElementStateHover
	ElementStateActive
	ElementStateFocused
	ElementStateFocusedVisible
	ElementStateFocusedWithin

	// Resource states
	ElementStatePlaying
	ElementStatePaused
	ElementStateWaiting

	// Input states
	ElementStateAutofilled
	ElementStateEnabled
	ElementStateDisabled
	ElementStateReadOnly
	ElementStateWriteOnly
	ElementStateSelected
	ElementStateChecked
	ElementStateVisited
	ElementStateHidden

	// Drag states
	ElementStateDragEnter
	ElementStateDragStart
	ElementStateDragging
	ElementStateDragEnd
	ElementStateDragExit
	ElementStateDroped
	ElementStateLeaved
	ElementStateDragOver
)

Considerations

  • Spec Broken: I know it can break exiting HTML5 specs, But we can easily just deprecate old duplicate functions in HTML6 not now!
  • Indeed need more discussion on details!!
@Yay295
Copy link
Contributor

Yay295 commented Aug 11, 2021

Just fyi, in English we usually end our sentences with a period. Exclamation marks are used for exclamations, and when you use it all the time it sounds like you're shouting.

@Yay295
Copy link
Contributor

Yay295 commented Aug 11, 2021

Improve HTML spec in semantic aspect!

How does this do that? "semantic aspect" is a pretty broad term, so could you be more specific?

Standard[ize] all elements states under one attribute. Exiting state attributes usually as[re] boolean attributes and even some hidden attributes that [are] use by everyone like pseudo-classes in CSS!

CSS states are already pretty standardized I think, though if you know any outliers please let us know. I think HTML attributes are also mostly standardized, though a lot of them only share the same name; the attribute itself technically isn't the same. I think that could be solved by adding more interfaces though. For example:

For example, we need an open boolean state attribute in <details> also in <dialog> and even non-standard tag like <popup> (I don't think popup tag is good enough to be in the HTML standard!) and it can standard under state="" attribute!

This could be unified by having an HTMLOpenableElement interface that each of the openable elements extends from, I think.

Have global and standard onStateChange() listener to check if any state changed to an element!

I think a new interface similar to MutationObserver could be used here instead of adding a new HTML attribute or event.

Solve many problems like those discussed at ...

I don't see how this proposal solves either of those problems. Could you give some examples?

@domenic
Copy link
Member

domenic commented Aug 11, 2021

I don't think this adds any concrete value, and instead just confuses the matter by adding two ways to do things. So, I'll close this.

@domenic domenic closed this as completed Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants