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

Establish a rule about element overloading #502

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

martinthomson
Copy link
Contributor

@martinthomson martinthomson commented Jul 15, 2024

I'm sure that we could say more, but I think that this is enough.

Closes #370.


Preview | Diff

I'm sure that we could say more, but I think that this is enough.

Closes #370.
Copy link
Contributor

@hober hober left a comment

Choose a reason for hiding this comment

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

Looks good to me.

but attributes should not fundamentally alter that purpose.

Rather than defining elements that can operate in different modes,
having a separate element for each mode is preferable.
Copy link
Contributor

Choose a reason for hiding this comment

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

Counterexample: <legend>, <caption>, and <figcaption> probably should have all been the same element (but can't be for compat reasons).

The now-deprecated <{acronym}> element is duplicative of the <{abbr}> element
and therefore overspecialization.
The <{source}> element can have distinct purposes depending on context.
A <{source}> element is not standalone; it's semantics are determined by its parent.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
A <{source}> element is not standalone; it's semantics are determined by its parent.
A <{source}> element is not standalone; its semantics are determined by its parent.

@hober
Copy link
Contributor

hober commented Jul 15, 2024

It would be nice for a non-native English speaker to take an editorial pass on this.

This simplifies usage for authors.

<div class=example>
The <{input}> element uses a <{input/type}> attribute to switch between
Copy link
Member

Choose a reason for hiding this comment

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

<link> is another good example to include here.


<div class=example>
The <{textarea}> element and an <{input}> element with a <{input/type}> of `"text"`
could have used the same element as the differences between these is not material.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
could have used the same element as the differences between these is not material.
could have used the same element as the differences between these are not material.

</div>

Potential counterexamples include overspecialization and elements that rely on context to establish their semantics.
The now-deprecated <{acronym}> element is duplicative of the <{abbr}> element
Copy link
Member

Choose a reason for hiding this comment

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

This should be in a <div class=example>

Potential counterexamples include overspecialization and elements that rely on context to establish their semantics.
The now-deprecated <{acronym}> element is duplicative of the <{abbr}> element
and therefore overspecialization.
The <{source}> element can have distinct purposes depending on context.
Copy link
Member

Choose a reason for hiding this comment

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

This should also be in a (different) <div class=example>.

I disagree that this is an antipattern. The purpose of <source> is clear, the details change based on its context which is fine — having distinct elements would have been an antipattern just like <caption>/<figcaption>/<legend> that @hober mentioned.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think Martin agrees with you. This suggests this needs to be reworded so that people don't misread him.

Comment on lines +1089 to +1092
through the use of attributes could be used to select
between different behavior.
This only makes sense where the purpose remains the same
for any value of the attributes.
Copy link
Member

Choose a reason for hiding this comment

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

This reads a little awkward. Maybe something like

Suggested change
through the use of attributes could be used to select
between different behavior.
This only makes sense where the purpose remains the same
for any value of the attributes.
through the use of attributes is valid when used to differentiate
behavior within the same purpose.

?

Copy link
Member

@LeaVerou LeaVerou left a comment

Choose a reason for hiding this comment

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

See comments.

I wonder if it might make sense to mention distinct elements sharing the same interface as a halfway solution, with the positive example of <video> and <audio> as instances of HTMLMediaElement. <h1> to <h6> could also be a counterexample of insufficient overloading.

@LeaVerou
Copy link
Member

It would be nice for a non-native English speaker to take an editorial pass on this.

🙋🏽‍♀️

Comment on lines +1084 to +1085
The semantics of these modes could have been more clearly expressed
through the use of distinct element names.
Copy link
Member

Choose a reason for hiding this comment

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

While this is true, I wouldn't want people to walk away with the idea that we should completely abandon input. Making minor changes to input seems clearly preferable to creating a whole new element.

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.

New principle: Discourage overloading (in HTML)
4 participants