File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change 1234
1234
styles = element . styles ,
1235
1235
origClasses = attrs [ 'class' ] ,
1236
1236
origStyles = attrs . style ,
1237
- name ,
1237
+ name , origName ,
1238
1238
stylesArr = [ ] ,
1239
1239
classesArr = [ ] ,
1240
1240
internalAttr = / ^ d a t a - c k e - / ,
1248
1248
// We can safely remove class and styles attributes because they will be serialized later.
1249
1249
for ( name in attrs ) {
1250
1250
// If not valid and not internal attribute delete it.
1251
- if ( ! validAttrs [ name ] && ! internalAttr . test ( name ) ) {
1252
- delete attrs [ name ] ;
1253
- isModified = true ;
1251
+ if ( ! validAttrs [ name ] ) {
1252
+ // Allow all internal attibutes...
1253
+ if ( internalAttr . test ( name ) ) {
1254
+ // ... unless this is a saved attribute and the original one isn't allowed.
1255
+ if ( name != ( origName = name . replace ( / ^ d a t a - c k e - s a v e d - / , '' ) ) &&
1256
+ ! validAttrs [ origName ]
1257
+ ) {
1258
+ delete attrs [ name ] ;
1259
+ isModified = true ;
1260
+ }
1261
+ } else {
1262
+ delete attrs [ name ] ;
1263
+ isModified = true ;
1264
+ }
1254
1265
}
1266
+
1255
1267
}
1256
1268
}
1257
1269
1290
1302
1291
1303
switch ( element . name ) {
1292
1304
case 'a' :
1293
- attrs = element . attributes ;
1294
- if ( ! attrs . href && ! attrs . name )
1295
- return false ;
1296
- if ( ! attrs . name && ! element . children . length )
1305
+ // Code borrowed from htmlDataProcessor, so ACF does the same clean up.
1306
+ if ( ! ( element . children . length || element . attributes . name ) )
1297
1307
return false ;
1298
1308
break ;
1299
1309
case 'img' :
You can’t perform that action at this time.
0 commit comments