[w3c/editing] Unlinking algorithm always removes anchor element (#246)

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](https://w3c.github.io/editing/ActiveDocuments/execCommand.html#the-unlink-command), it [clears the value](https://w3c.github.io/editing/ActiveDocuments/execCommand.html#clear-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](https://w3c.github.io/editing/ActiveDocuments/execCommand.html#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?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/editing/issues/246

Received on Monday, 4 May 2020 19:38:13 UTC