Closed Bug 248349 Opened 22 years ago Closed 4 years ago

Editor discards empty anchor tags specified with ID instead of NAME

Categories

(Core :: DOM: Editor, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: mcow, Unassigned)

Details

Attachments

(2 files)

In Composer and the HTML Mail editor, it is not possible to include an anchor that has an ID instead of a NAME. This is true for pasting text with such an anchor from the browser, or when using Insert|HTML or editing the HTML view in Composer. Steps to reproduce: In Composer: 1) open a new window, or open an existing file. Go to HTML Source tab. Put cursor at some reasonable point in the <body> -- e.g. within text. 2) type: <a id="foo"></a> 3) go to HTML Tags tab 4) return to HTML Source tab Actual results: After step 3, there is no visible placeholder (either [A] or the anchor) where the tag was entered. After step 4, the tag that was entered is no longer present Expected results: placeholder should be visible on HTML Tags view, preferably as the anchor; tag text should continue to be present. A non-empty tag: <a id="bar">BAR</a> is maintained in the source; the placeholder is [A] rather than the anchor symbol, altho a link to #bar will work as expected. An empty tag with name: <a name="ok"></a> is maintained, and its placeholder is the anchor. Same results are seen using Insert|HTML, in both Composer and in HTML mail. (To view the HTML source in mail, select the entire text and then Insert|HTML.) Opening a file in composer that contains an empty, ID-spec'd anchor works as expected, except that [A] is displayed on the Tags view rather than the anchor symbol. Also note: after such a file has been opened, if Insert|Link is selected, the dropdown list of possible links includes both the id-specified and the name-specified anchors.
Attached file Test data file —
Alternate path to reproduce: Open this attachment in Mozilla browser Select all text, and copy to clipboard Open new composer window Paste copied text in Go to HTML Source tab Actual results: the empty <a id="foo"></a> tag (eight line of text) is not present Expected results: it oughtta be!
QA Contact: bugzilla → editor
Assignee: mozeditor → nobody
confirmed, taking.
Assignee: nobody → daniel
Status: NEW → ASSIGNED
OS: Windows 2000 → All
Hardware: x86 → All
This is because nsHTMLEditRules consider an empty a element that has no name attribute as removable (sigh).
Attached patch proposed fix — — Splinter Review
This fix is not optimal since we should really revamp all this part of the editor: if removing useless elements makes sense for the editor in Thunderbird, it does not make sense in a lot of cases in the Markup editor. But since this bug severely affects editability of HTML5 anchors (using IDs and not names any more), I suggest we don't wait so here's a trivial fix for the bug.
Attachment #463136 - Flags: review?(neil)
Comment on attachment 463136 [details] [diff] [review] proposed fix Could you also add a test for this, please? Thanks!
Attachment #463136 - Flags: review?(neil) → review+

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: daniel → nobody
Status: ASSIGNED → NEW

I don't reproduce this bug with copying the testcase and pasting it into contenteditable.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: