a55b489c8ba3cd92a96f4de6e67484c569855902
[ckeditor.git] / _source / core / htmlparser / comment.js
1 /*
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
4 */
5
6 /**
7 * A lightweight representation of an HTML comment.
8 * @constructor
9 * @example
10 */
11 CKEDITOR.htmlParser.comment = function( value )
12 {
13 /**
14 * The comment text.
15 * @type String
16 * @example
17 */
18 this.value = value;
19
20 /** @private */
21 this._ =
22 {
23 isBlockLike : false
24 };
25 };
26
27 CKEDITOR.htmlParser.comment.prototype =
28 {
29 /**
30 * The node type. This is a constant value set to {@link CKEDITOR.NODE_COMMENT}.
31 * @type Number
32 * @example
33 */
34 type : CKEDITOR.NODE_COMMENT,
35
36 /**
37 * Writes the HTML representation of this comment to a CKEDITOR.htmlWriter.
38 * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
39 * @example
40 */
41 writeHtml : function( writer, filter )
42 {
43 var comment = this.value;
44
45 if ( filter )
46 {
47 if ( !( comment = filter.onComment( comment, this ) ) )
48 return;
49
50 if ( typeof comment != 'string' )
51 {
52 comment.parent = this.parent;
53 comment.writeHtml( writer, filter );
54 return;
55 }
56 }
57
58 writer.comment( comment );
59 }
60 };