-
Notifications
You must be signed in to change notification settings - Fork 385
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
MSC4159: Remove the deprecated name attribute on HTML anchor elements #4159
Merged
turt2live
merged 1 commit into
matrix-org:main
from
Johennes:johannes/remove-anchor-name
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# MSC4159: Remove the deprecated name attribute on HTML anchor elements | ||
|
||
Some message types in `m.room.message`, such as `m.text`, permit including HTML in the event content. | ||
The spec [recommends] that clients limit the HTML they render to prevent attacks and provides a list | ||
of permitted HTML tags and attributes. In particular, it allows using the `name` attribute on `a` tags. | ||
This attribute is obsolete according to the [WHATWG HTML Living Standard] which is why this proposal | ||
attempts to remove it from the spec. | ||
|
||
|
||
## Proposal | ||
|
||
The `name` attribute was originally introduced to define targets for linking to specific parts of a | ||
webpage. As an example, including the named anchor `<a name="foo">bar</a>` on a site allows you to append | ||
the fragment `#foo` to the URL to cause your browser to scroll the anchor into view after loading the page. | ||
|
||
In modern versions of HTML this feature has been superseded by the `id` attribute which extends targeted | ||
linking to more than just `a` tags. As a result, the `name` attribute is marked deprecated in [MDN]. | ||
|
||
> Was required to define a possible target location in a page. In HTML 4.01, `id` and `name` could | ||
> both be used on `<a>`, as long as they had identical values. | ||
> | ||
> Note: Use the global attribute `id` instead. | ||
|
||
Furthermore, it is also tracked as [obsolete but conforming] in WHATWG. | ||
|
||
> Authors should not specify the `name` attribute on `a` elements. If the attribute is present, its value | ||
> must not be the empty string and must neither be equal to the value of any of the IDs in the element's | ||
> tree other than the element's own ID, if any, nor be equal to the value of any of the other `name` | ||
> attributes on `a` elements in the element's tree. If this attribute is present and the element has an ID, | ||
> then the attribute's value must be equal to the element's ID. In earlier versions of the language, this | ||
> attribute was intended as a way to specify possible targets for fragments in URLs. The `id` attribute | ||
> should be used instead. | ||
|
||
On top of the deprecation of the `name` attribute in HTML, it is unclear what this feature would ever have | ||
been used for in the context of Matrix. It appears highly undesirable to let events define targeted links | ||
into a client's UI, not least because the value of the `name` attribute would need to be unique on the | ||
entire page. Additionally, linking to specific events is already possible via [matrix.to URIs]. | ||
|
||
Therefore, the `name` attributed is removed from the list of permitted attributes on `a` tags without a | ||
replacement. | ||
|
||
|
||
## Potential issues | ||
|
||
Use cases that currently depend on the `name` attribute will be broken once the attribute is removed from | ||
the allowed list. No concrete use cases are known as of writing, however. | ||
|
||
|
||
## Alternatives | ||
|
||
None. | ||
|
||
|
||
## Security considerations | ||
|
||
None. | ||
|
||
|
||
## Unstable prefix | ||
|
||
None. | ||
|
||
|
||
## Dependencies | ||
|
||
None. | ||
|
||
|
||
[MDN]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#name | ||
[WHATWG HTML Living Standard]: https://html.spec.whatwg.org/ | ||
[matrix.to URIs]: https://spec.matrix.org/v1.10/appendices/#matrixto-navigation | ||
[obsolete but conforming]: https://html.spec.whatwg.org/#obsolete-but-conforming-features | ||
[recommends]: https://spec.matrix.org/v1.10/client-server-api/#mroommessage-msgtypes |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation requirements: