Skip to content

Commit 6c8624e

Browse files
committed
Merge branch 't/9981' into major
2 parents 5135d41 + c76477e commit 6c8624e

File tree

9 files changed

+373
-167
lines changed

9 files changed

+373
-167
lines changed

core/htmlparser/cdata.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
* For licensing, see LICENSE.html or http://ckeditor.com/license
44
*/
55

6+
'use strict';
7+
68
(function() {
79

810
/**
9-
* A lightweight representation of HTML text.
11+
* A lightweight representation of HTML CDATA.
1012
*
1113
* @class
14+
* @extends CKEDITOR.htmlParser.node
1215
* @constructor Creates a cdata class instance.
1316
* @param {String} value The CDATA section value.
1417
*/
@@ -21,7 +24,7 @@
2124
this.value = value;
2225
};
2326

24-
CKEDITOR.htmlParser.cdata.prototype = {
27+
CKEDITOR.htmlParser.cdata.prototype = CKEDITOR.tools.extend( new CKEDITOR.htmlParser.node(), {
2528
/**
2629
* CDATA has the same type as {@link CKEDITOR.htmlParser.text} This is
2730
* a constant value set to {@link CKEDITOR#NODE_TEXT}.
@@ -31,6 +34,8 @@
3134
*/
3235
type: CKEDITOR.NODE_TEXT,
3336

37+
filter: function() {},
38+
3439
/**
3540
* Writes the CDATA with no special manipulations.
3641
*
@@ -39,5 +44,5 @@
3944
writeHtml: function( writer ) {
4045
writer.write( this.value );
4146
}
42-
};
47+
} );
4348
})();

core/htmlparser/comment.js

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
* For licensing, see LICENSE.html or http://ckeditor.com/license
44
*/
55

6+
'use strict';
7+
68
/**
79
* A lightweight representation of an HTML comment.
810
*
911
* @class
12+
* @extends CKEDITOR.htmlParser.node
1013
* @constructor Creates a comment class instance.
1114
* @param {String} value The comment text value.
1215
*/
@@ -24,7 +27,7 @@ CKEDITOR.htmlParser.comment = function( value ) {
2427
};
2528
};
2629

27-
CKEDITOR.htmlParser.comment.prototype = {
30+
CKEDITOR.htmlParser.comment.prototype = CKEDITOR.tools.extend( new CKEDITOR.htmlParser.node(), {
2831
/**
2932
* The node type. This is a constant value set to {@link CKEDITOR#NODE_COMMENT}.
3033
*
@@ -34,24 +37,41 @@ CKEDITOR.htmlParser.comment.prototype = {
3437
type: CKEDITOR.NODE_COMMENT,
3538

3639
/**
37-
* Writes the HTML representation of this comment to a CKEDITOR.htmlWriter.
40+
* Filter this comment with given filter.
3841
*
39-
* @param {CKEDITOR.htmlParser.basicWriter} writer The writer to which write the HTML.
42+
* @param {CKEDITOR.htmlParser.filter} filter
43+
* @returns {Boolean} Method returns `false` when this comment has
44+
* been removed or replaced with other node. This is an information for
45+
* {@link CKEDITOR.htmlParser.element#filterChildren} that it has
46+
* to repeat filter on current position in parent's children array.
4047
*/
41-
writeHtml: function( writer, filter ) {
48+
filter: function( filter ) {
4249
var comment = this.value;
4350

44-
if ( filter ) {
45-
if ( !( comment = filter.onComment( comment, this ) ) )
46-
return;
51+
if ( !( comment = filter.onComment( comment, this ) ) ) {
52+
this.remove();
53+
return false;
54+
}
4755

48-
if ( typeof comment != 'string' ) {
49-
comment.parent = this.parent;
50-
comment.writeHtml( writer, filter );
51-
return;
52-
}
56+
if ( typeof comment != 'string' ) {
57+
this.replaceWith( comment );
58+
return false;
5359
}
5460

55-
writer.comment( comment );
61+
this.value = comment;
62+
},
63+
64+
/**
65+
* Writes the HTML representation of this comment to a CKEDITOR.htmlWriter.
66+
*
67+
* @param {CKEDITOR.htmlParser.basicWriter} writer The writer to which write the HTML.
68+
* @param {CKEDITOR.htmlParser.filter} [filter] The filter to be applied to this node.
69+
* **Note:** it's unsafe to filter offline (not appended) node.
70+
*/
71+
writeHtml: function( writer, filter ) {
72+
if ( filter )
73+
this.filter( filter );
74+
75+
writer.comment( this.value );
5676
}
57-
};
77+
} );

0 commit comments

Comments
 (0)