Opened 9 years ago

Last modified 9 years ago

#12942 confirmed Bug

Anchors require deprecated name tag, id should be enough

Reported by: Allan Mørk Christensen Owned by:
Priority: Normal Milestone:
Component: Core : Parser Version: 4.1
Keywords: Cc: allanmc@…

Description

If i insert an <a> with only an id attribute and no name attribute, it will simply be discarded by CKEditor.

Tested in latest version of the demo: http://ckeditor.com/demo

Steps to reproduce

  • Insert the following HTML in SOURCE-mode:
    <p>hello <a name="xxx" id="xxx">xxx</a> hello</p>
    <p>hello <a id="yyy">yyy</a> hello</p>
    
  • Go back to WYSIWYG mode, and now only the first (xxx) anchor is visible.
  • If you again return back to SOURCE-mode, the second (yyy) anchor has complete vanished.

In HTML5 the "name" attribute for <a> is been obsolete, "id" should be used instead: http://www.w3.org/TR/html-markup/a.html#a-constraints

Change History (2)

comment:1 Changed 9 years ago by Allan Mørk Christensen

Cc: allanmc@… added

comment:2 Changed 9 years ago by Jakub Ś

Keywords: anchor name id html5 a removed
Status: newconfirmed
Version: 4.4.74.1

We still need name attribute because we support HTML 4 as well but anchor with sole id attribute is valid and should not be removed by editor.

I'm not exactly sure why ACF removes this tag (because it works with name attribute) but problem can be worked around with below code:

var editor = CKEDITOR.replace( 'editor1', {
extraAllowedContent : 'a[id]'
});
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy