Opened 11 years ago
Closed 6 years ago
#27530 closed defect (bug) (duplicate)
Anchor tag wrapped around div tag would add extra paragraph tag
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.8.1 |
Component: | Editor | Keywords: | needs-testing has-patch |
Focuses: | Cc: |
Description (last modified by )
(WordPress version 3.9-Alpha 27111)
This is HTML we added to our page editor:
<div><a href="#"><div>testing</div></a></div>
This is source result we are getting in browser:
<div><a href="#"> <div>testing</div> <p></a></div>
For some reason <p> tag have been added. This happens every time block element is inside the anchor tag, we tried with <section> as well. When <span> is used instead all works fine.
Attachments (1)
Change History (7)
#4
@
9 years ago
- Keywords has-patch added; needs-patch removed
Was able to replicate this on the latest version of trunk (4.4-beta4-35721). The issue stems from the wpautop
function. It ends up breaking the content into multiple pieces and then wraps paragraphs around each piece. The last piece in this situation ends up being </a></div>
, which we don't want paragraphs around that.
I've added a patch that fixes this particular use case, basically it makes sure we don't wrap paragraphs around closing tags. I'm sure there's other ways to fix this so open to any suggestions.
Also, could see this as being a don't-fix, as technically we don't want block level elements inside inline elements, which is what's happening here. I believe HTML5 does allow that though, so might be worth fixing.
Hello! Thanks for the bug report. I actually see this same issue in 3.8.1, so it looks like it's not a new regression.