w3c / w3c/editing

Unlinking algorithm always removes anchor element

Open
#246 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
202
Forks
43
PR merge metrics
No merged PRs in 30d

Description

We have a behavior difference in Firefox and Chrome where Firefox replaces an anchor with <span> when it has extra attributes while Chrome does not.

Repro: https://bug378931.bmoattachments.org/attachment.cgi?id=263746

Per the unlink command algorithm, it clears the value of the target anchor elements, where it removes href attribute in step 9. And then its step 10 has this note:

If we get past this step, we're something like <b class=foo> where we want to keep the extra attributes, so we stick them on a span.

Per the note the purpose of it is to keep the extra attributes of the element. But then the step says:

If element's specified command value for command is null, return the empty list.

Here, the "specified command value" becomes always null for "unlink" because the previous step just removed href:

If command is "createLink" or "unlink":
If element is an a element and has an href attribute, return the value of that attribute.
Return null.

Since the value is always null, the anchor elements always must disappear regardless of extra attributes.

The spec agrees with Chrome behavior but the note clearly suggests the original intention was for Firefox behavior.

What should be done here? Should Firefox be fixed or the spec?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked execCommand unlink-command and clear-the-value sections, then reproduce attachment 263746 in Firefox and Chrome. Compare the observed behavior with steps 9 and 10 and the specified command value definition. Done means resolving whether the browser behavior or the specification should change.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
frontend, web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.