JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.3
[ckeditor.git] / _source / core / dom / comment.js
1 /*\r
2 Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license\r
4 */\r
5 \r
6 /**\r
7  * @fileOverview Defines the {@link CKEDITOR.dom.comment} class, which represents\r
8  *              a DOM comment node.\r
9  */\r
10 \r
11 /**\r
12  * Represents a DOM comment node.\r
13  * @constructor\r
14  * @augments CKEDITOR.dom.node\r
15  * @param {Object|String} comment A native DOM comment node or a string containing\r
16  *              the text to use to create a new comment node.\r
17  * @param {CKEDITOR.dom.document} [ownerDocument] The document that will contain\r
18  *              the node in case of new node creation. Defaults to the current document.\r
19  * @example\r
20  * var nativeNode = document.createComment( 'Example' );\r
21  * var comment = CKEDITOR.dom.comment( nativeNode );\r
22  * @example\r
23  * var comment = CKEDITOR.dom.comment( 'Example' );\r
24  */\r
25 CKEDITOR.dom.comment = function( comment, ownerDocument )\r
26 {\r
27         if ( typeof comment == 'string' )\r
28                 comment = ( ownerDocument ? ownerDocument.$ : document ).createComment( comment );\r
29 \r
30         CKEDITOR.dom.domObject.call( this, comment );\r
31 };\r
32 \r
33 CKEDITOR.dom.comment.prototype = new CKEDITOR.dom.node();\r
34 \r
35 CKEDITOR.tools.extend( CKEDITOR.dom.comment.prototype,\r
36         /** @lends CKEDITOR.dom.comment.prototype */\r
37         {\r
38                 type : CKEDITOR.NODE_COMMENT,\r
39 \r
40                 getOuterHtml : function()\r
41                 {\r
42                         return '<!--' + this.$.nodeValue + '-->';\r
43                 }\r
44         });\r