Skip to content

Commit

Permalink
Merge branch 't/9981' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Jan 23, 2013
2 parents 5135d41 + c76477e commit 6c8624e
Show file tree
Hide file tree
Showing 9 changed files with 373 additions and 167 deletions.
11 changes: 8 additions & 3 deletions core/htmlparser/cdata.js
Expand Up @@ -3,12 +3,15 @@
* For licensing, see LICENSE.html or http://ckeditor.com/license
*/

'use strict';

(function() {

/**
* A lightweight representation of HTML text.
* A lightweight representation of HTML CDATA.
*
* @class
* @extends CKEDITOR.htmlParser.node
* @constructor Creates a cdata class instance.
* @param {String} value The CDATA section value.
*/
Expand All @@ -21,7 +24,7 @@
this.value = value;
};

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

filter: function() {},

/**
* Writes the CDATA with no special manipulations.
*
Expand All @@ -39,5 +44,5 @@
writeHtml: function( writer ) {
writer.write( this.value );
}
};
} );
})();
48 changes: 34 additions & 14 deletions core/htmlparser/comment.js
Expand Up @@ -3,10 +3,13 @@
* For licensing, see LICENSE.html or http://ckeditor.com/license
*/

'use strict';

/**
* A lightweight representation of an HTML comment.
*
* @class
* @extends CKEDITOR.htmlParser.node
* @constructor Creates a comment class instance.
* @param {String} value The comment text value.
*/
Expand All @@ -24,7 +27,7 @@ CKEDITOR.htmlParser.comment = function( value ) {
};
};

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

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

if ( filter ) {
if ( !( comment = filter.onComment( comment, this ) ) )
return;
if ( !( comment = filter.onComment( comment, this ) ) ) {
this.remove();
return false;
}

if ( typeof comment != 'string' ) {
comment.parent = this.parent;
comment.writeHtml( writer, filter );
return;
}
if ( typeof comment != 'string' ) {
this.replaceWith( comment );
return false;
}

writer.comment( comment );
this.value = comment;
},

/**
* Writes the HTML representation of this comment to a CKEDITOR.htmlWriter.
*
* @param {CKEDITOR.htmlParser.basicWriter} writer The writer to which write the HTML.
* @param {CKEDITOR.htmlParser.filter} [filter] The filter to be applied to this node.
* **Note:** it's unsafe to filter offline (not appended) node.
*/
writeHtml: function( writer, filter ) {
if ( filter )
this.filter( filter );

writer.comment( this.value );
}
};
} );

0 comments on commit 6c8624e

Please sign in to comment.