[wp-trac] [WordPress Trac] #57313: Adding a menu item without a link URL should not add a broken HTML a tag
WordPress Trac
noreply at wordpress.org
Sun Dec 11 20:42:48 UTC 2022
#57313: Adding a menu item without a link URL should not add a broken HTML a tag
--------------------------+------------------------------
Reporter: cliffpaulick | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Menus | Version: 6.1.1
Severity: normal | Resolution:
Keywords: dev-feedback | Focuses:
--------------------------+------------------------------
Changes (by costdev):
* keywords: => dev-feedback
Comment:
Thanks for opening this ticket @cliffpaulick!
Some info for those reading this ticket:
>If the a element has no `href` attribute, then the element represents a
placeholder for where a link might otherwise have been placed, if it had
been relevant, consisting of just the element's contents.
>
>The `target`, `download`, `ping`, `rel`, `hreflang`, `type`, and
`referrerpolicy` attributes must be omitted if the `href` attribute is not
present.
>
>**If the `itemprop` attribute is specified on an a element, then the
`href` attribute must also be specified.**
(my emphasis)
Source: [https://html.spec.whatwg.org/#the-a-element HTML spec for <a>
tag]
- The link is invalid because it has an `itemprop` attribute, which
requires an `href` attribute that isn't present.
- I don't see this being added by Core anywhere, so I assume it's being
added by a plugin or theme. In this case, the plugin/theme is failing to
check the `href` value to determine whether `itemprop` should be added. If
this is a bundled theme, we should correct this behaviour. If this is a
third party theme/plugin, a ticket should be raised in the support forum
for the plugin/theme.
Aside from that, this is only possible because Core doesn't fully validate
the `URL` field.
- Currently, you can't add an empty URL via `Appearance > Menus` or via
`Customize > Menus`.
- However, on both screens, you can ''edit an existing link'' to remove
the URL. i.e. Incomplete validation.
- I think this should be the focus for discussion on this ticket. Should
we add this missing validation?
If there is a desire for Core to allow plain text menu items, this should
be created as a separate `enhancement` ticket.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57313#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list