Skip to content
Permalink
Browse files

Merge branch 't/13516b'

  • Loading branch information...
szymonkups committed Sep 22, 2015
2 parents 623ade3 + e554ff7 commit 1f1a9b318bedde455a3b7d7c732537a2e031a9cf
@@ -20,6 +20,7 @@ Fixed Issues:
* [#11724](http://dev.ckeditor.com/ticket/11724): [Touch devices] Fixed: Drop-downs often hide right after opening them.
* [#13690](http://dev.ckeditor.com/ticket/13690): Fixed: Copying content from IE to Chrome adding extra paragraph.
* [#13284](http://dev.ckeditor.com/ticket/13284): Fixed: Cannot drag and drop a widget if a text caret is placed just after widget instance.
* [#13516](http://dev.ckeditor.com/ticket/13516): Fixed: CKEditor removes empty html5 anchors without name attribute.

Other Changes:

@@ -1689,7 +1689,7 @@
switch ( element.name ) {
case 'a':
// Code borrowed from htmlDataProcessor, so ACF does the same clean up.
if ( !( element.children.length || element.attributes.name ) )
if ( !( element.children.length || element.attributes.name || element.attributes.id ) )
return false;
break;
case 'img':
@@ -602,9 +602,11 @@
}
},

// Remove empty link but not empty anchor. (#3829)
// Remove empty link but not empty anchor. (#3829, #13516)
a: function( element ) {
if ( !( element.children.length || element.attributes.name || element.attributes[ 'data-cke-saved-name' ] ) )
var attrs = element.attributes;

if ( !( element.children.length || attrs.name || attrs.id || element.attributes[ 'data-cke-saved-name' ] ) )
return false;
}
}
@@ -619,11 +619,18 @@
filter( '<p>X<a name="x">A</a>X</p>', '<p>X<a name="x">A</a>X</p>' );
filter( '<p>X<a name="x"><img src="x" /></a>X</p>', '<p>X<a name="x"></a>X</p>' );
filter( '<p>X<a href="x" name="x">A</a>X</p>', '<p>X<a name="x">A</a>X</p>' );
// Empty <a> element isn't correct unless it is an anchor (has non-empty name attrbiute).
// Empty <a> element isn't correct unless it is an anchor (has non-empty name or id attrbiute).
// This behaviour conforms to the htmlDP's htmlFilter.
filter( '<p>X<a href="x" name=""></a>X</p>', '<p>XX</p>' );
filter( '<p>X<a name="x" href="x"><img /></a>X</p>', '<p>X<a name="x"></a>X</p>' );

filter = createFilter( 'p; a[!id]' );
filter( '<p>X<a name="x"></a>X</p>', '<p>XX</p>' );
filter( '<p>X<a id=""></a>X</p>', '<p>XX</p>' );
filter( '<p>X<a id="x"></a>X</p>', '<p>X<a id="x"></a>X</p>' );
filter( '<p>X<a id="x" name="x"></a>X</p>', '<p>X<a id="x"></a>X</p>' );
filter( '<p>X<a id="x" name="x">foo</a>X</p>', '<p>X<a id="x">foo</a>X</p>' );

filter = createFilter( 'p; a[!href]' );

filter( '<p>X<a href="">A</a>X</p>', '<p>X<a href="">A</a>X</p>' );
@@ -124,6 +124,7 @@
setUp: function() {
// Force result data un-formatted.
this.editor.dataProcessor.writer._.rules = {};
this.editor.dataProcessor.writer.sortAttributes = true;
this.editor.focus();
},

@@ -391,19 +392,49 @@
assert.areSame( html , dataProcessor.toDataFormat( protectedHtml ) );
},

/**
* Test empty value attributes.
*/
test_ticket_3884: function() {
var editor = this.editor,
dataProcessor = editor.dataProcessor;
dataProcessor.writer = new CKEDITOR.htmlParser.basicWriter();
dataProcessor.writer.sortAttributes = true;
'test link with empty href': function() {
var dataProcessor = this.editor.dataProcessor;

assert.areSame( '<p><a href="" name="">emptylink</a></p>',
dataProcessor.toDataFormat( dataProcessor.toHtml( '<p><a href="" name="">emptylink</a></p>' ) ) );
},

'test empty link': function() {
var dataProcessor = this.editor.dataProcessor;

assert.areSame( '<p>xx</p>', dataProcessor.toDataFormat( '<p>x<a href="foo"></a>x</p>' ), 'toDF' );

assert.areSame( '<p>xx</p>', dataProcessor.toHtml( '<p>x<a href="foo"></a>x</p>' ), 'toHtml' );
},

'test empty anchor with name': function() {
var dataProcessor = this.editor.dataProcessor;

assert.areSame( '<p>x<a name="foo"></a>x</p>',
dataProcessor.toDataFormat( '<p>x<a data-cke-saved-name="foo" name="foo"></a>x</p>' ), 'toDF' );

assert.areSame( '<p>x<a data-cke-saved-name="foo" name="foo"></a>x</p>',
dataProcessor.toHtml( '<p>x<a name="foo"></a>x</p>' ), 'toHtml' );
},

'test empty anchor with id': function() {
var dataProcessor = this.editor.dataProcessor;

assert.areSame( '<p>x<a id="foo"></a>x</p>', dataProcessor.toDataFormat( '<p>x<a id="foo"></a>x</p>' ), 'toDF' );

assert.areSame( '<p>x<a id="foo"></a>x</p>', dataProcessor.toHtml( '<p>x<a id="foo"></a>x</p>' ), 'toHtml' );
},

'test empty anchor with name and id': function() {
var dataProcessor = this.editor.dataProcessor;

assert.areSame( '<p>x<a id="bar" name="foo"></a>x</p>',
dataProcessor.toDataFormat( '<p>x<a data-cke-saved-name="foo" id="bar" name="foo"></a>x</p>' ), 'toDF' );

assert.areSame( '<p>x<a data-cke-saved-name="foo" id="bar" name="foo"></a>x</p>',
bender.tools.fixHtml( dataProcessor.toHtml( '<p>x<a id="bar" name="foo"></a>x</p>' ) ), 'toHtml' );
},

test_innerHtmlComments_ticket_3801: function() {
var editor = this.editor,
dataProcessor = editor.dataProcessor;
@@ -316,6 +316,38 @@
'test header elements in summary tag': function() {
assert.areSame( '<summary><h2>Summary</h2></summary>',
htmlParse( '<summary><h2>Summary</h2></summary>' ) );
},

'test link': function() {
assert.areSame( '<a href="foo">bar</a>', htmlParse( '<a href="foo">bar</a>' ) );
},

'test empty link': function() {
assert.areSame( '', htmlParse( '<a href="foo"></a>' ) );
},

'test anchor with name': function() {
assert.areSame( '<a name="foo">bar</a>', htmlParse( '<a name="foo">bar</a>' ) );
},

'test anchor with id': function() {
assert.areSame( '<a id="foo">bar</a>', htmlParse( '<a id="foo">bar</a>' ) );
},

'test anchor with name and id': function() {
assert.areSame( '<a id="foo" name="bom">bar</a>', htmlParse( '<a id="foo" name="bom">bar</a>' ) );
},

'test empty anchor with name': function() {
assert.areSame( '<a name="foo"></a>', htmlParse( '<a name="foo"></a>' ) );
},

'test empty anchor with id': function() {
assert.areSame( '<a id="foo"></a>', htmlParse( '<a id="foo"></a>' ) );
},

'test empty anchor with name and id': function() {
assert.areSame( '<a id="foo" name="bom"></a>', htmlParse( '<a id="foo" name="bom"></a>' ) );
}
} );

0 comments on commit 1f1a9b3

Please sign in to comment.
You can’t perform that action at this time.