Skip to content

Commit 4819724

Browse files
committed
Prevent ACF from striping spans with data-cke-* to preserve makers.
1 parent 94f756e commit 4819724

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

core/filter.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,22 @@
278278

279279
// Filter all children, skip root (fragment or editable-like wrapper used by data processor).
280280
fragment.forEach( function( el ) {
281-
if ( el.type == CKEDITOR.NODE_ELEMENT ) {
282-
if ( filterFn( el, rules, transformations, toBeRemoved, toHtml ) )
283-
isModified = true;
284-
}
285-
else if ( el.type == CKEDITOR.NODE_COMMENT && el.value.match( /^\{cke_protected\}(?!\{C\})/ ) ) {
286-
if ( !filterProtectedElement( el, protectedRegexs, filterFn, rules, transformations, toHtml ) )
287-
toBeRemoved.push( el );
288-
}
289-
}, null, true );
281+
if ( el.type == CKEDITOR.NODE_ELEMENT ) {
282+
// (#10260) Don't touch elements like spans with data-cke-* attribute since they're
283+
// responsible e.g. for placing markers, bookmarks, odds and stuff.
284+
// We love 'em and we don't wanna lose anything during the filtering.
285+
// '|' is to avoid tricky joints like data-="foo" + cke-="bar". Yes, they're possible.
286+
if ( el.name == 'span' && ~CKEDITOR.tools.objectKeys( el.attributes ).join( '|' ).indexOf( 'data-cke-' ) )
287+
return;
288+
289+
if ( filterFn( el, rules, transformations, toBeRemoved, toHtml ) )
290+
isModified = true;
291+
}
292+
else if ( el.type == CKEDITOR.NODE_COMMENT && el.value.match( /^\{cke_protected\}(?!\{C\})/ ) ) {
293+
if ( !filterProtectedElement( el, protectedRegexs, filterFn, rules, transformations, toHtml ) )
294+
toBeRemoved.push( el );
295+
}
296+
}, null, true );
290297

291298
if ( toBeRemoved.length )
292299
isModified = true;

0 commit comments

Comments
 (0)