[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
Mon Dec 12 20:34:43 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:
--------------------------+------------------------------

Comment (by costdev):

 >@cliffpaulick I tested with Twenty Twenty-One and all plugins disabled
 and there was less markup but the a tag remained.
 >I then enabled Genesis child theme and the additional markup came
 through.

 Thanks for additional information!

 An empty `<a>` tag without `href` isn't invalid as mentioned by the HTML
 spec above - and, for example, could be targeted in CSS with
 `a:not([href])`. It seems the Genesis theme adds the `itemprop` attribute
 without checking whether doing so will produce an invalid `<a>` tag.
 That's understandable, given that WordPress Core tries to block the
 possibility of an empty `URL` in ''most'' cases.

 The `Menus` component considers an empty `URL` field to be invalid and
 prevents it in all cases except when editing an existing menu item. I
 consider this a bug in Core, and think we should make the validation
 consistent.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57313#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list