Opened 6 years ago

Closed 6 years ago

#10469 closed New Feature (invalid)

Request to Cache ID of Element on node.clone()

Reported by: dggtydnk Owned by:
Priority: Normal Milestone:
Component: Core : Parser Version:
Keywords: Cc:

Description

I have run into problems when doing a range.cloneContents() to get the selected HTML and the ID's of elements are being stripped out in the call to node.clone( true ), which triggers a false value for cloneID.

I would like to request that the ID be stored in a data attribute (i.e. data-cke-old-id) so that ID is available to developers if needed for any other processing of the document fragment returned from cloneContents(). For example, in node.js in the clone function, update to:

if( !cloneId ) {
   if( node.hasAttribute( "id" ) )
      node.setAttribute( "data-cke-old-id", node.getAttribute( "id" ) );
   node.removeAttribute( 'id', false );
}

Change History (1)

comment:1 Changed 6 years ago by Piotrek Koszuliński

Keywords: node clone preserve id removed
Resolution: invalid
Status: newclosed
Version: 4.1.1

Unfortunately, this is a very localized request, not related to the editor. We won't add such feature to the core, just to satisfy one case.

However, we could think of adding an argument to range.cloneContents(). In fact - I wonder how native implementations handle ids.

But since this addition would not be driven by any core need it has low priority for us. Thus, for you it'd be better to fork CKEditor and modify this function https://github.com/ckeditor/ckeditor-dev/blob/master/core/dom/range.js#L116. It is used by clone|delete|extractContents methods.

I'm closing this ticket. I extracted: #10473.

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy