JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.6.1
[ckeditor.git] / _source / core / dom / document.js
index e1026c1..a959fa5 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -150,7 +150,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.document.prototype,
 \r
                getElementsByTag : function( tagName, namespace )\r
                {\r
-                       if ( !CKEDITOR.env.ie && namespace )\r
+                       if ( !( CKEDITOR.env.ie && ! ( document.documentMode > 8 ) ) && namespace )\r
                                tagName = namespace + ':' + tagName;\r
                        return new CKEDITOR.dom.nodeList( this.$.getElementsByTagName( tagName ) );\r
                },\r
@@ -165,10 +165,12 @@ CKEDITOR.tools.extend( CKEDITOR.dom.document.prototype,
                getHead : function()\r
                {\r
                        var head = this.$.getElementsByTagName( 'head' )[0];\r
+                       if ( !head )\r
+                               head = this.getDocumentElement().append( new CKEDITOR.dom.element( 'head' ), true );\r
+                       else\r
                        head = new CKEDITOR.dom.element( head );\r
 \r
                        return (\r
-                       /** @ignore */\r
                        this.getHead = function()\r
                                {\r
                                        return head;\r
@@ -187,19 +189,21 @@ CKEDITOR.tools.extend( CKEDITOR.dom.document.prototype,
                        var body = new CKEDITOR.dom.element( this.$.body );\r
 \r
                        return (\r
-                       /** @ignore */\r
                        this.getBody = function()\r
                                {\r
                                        return body;\r
                                })();\r
                },\r
 \r
+               /**\r
+                * Gets the DOM document element for this document.\r
+                * @returns {CKEDITOR.dom.element} The DOM document element.\r
+                */\r
                getDocumentElement : function()\r
                {\r
                        var documentElement = new CKEDITOR.dom.element( this.$.documentElement );\r
 \r
                        return (\r
-                       /** @ignore */\r
                        this.getDocumentElement = function()\r
                                {\r
                                        return documentElement;\r
@@ -209,17 +213,39 @@ CKEDITOR.tools.extend( CKEDITOR.dom.document.prototype,
                /**\r
                 * Gets the window object that holds this document.\r
                 * @returns {CKEDITOR.dom.window} The window object.\r
-                * @example\r
                 */\r
                getWindow : function()\r
                {\r
                        var win = new CKEDITOR.dom.window( this.$.parentWindow || this.$.defaultView );\r
 \r
                        return (\r
-                       /** @ignore */\r
                        this.getWindow = function()\r
                                {\r
                                        return win;\r
                                })();\r
+               },\r
+\r
+               /**\r
+                * Defines the document contents through document.write. Note that the\r
+                * previous document contents will be lost (cleaned).\r
+                * @since 3.5\r
+                * @param {String} html The HTML defining the document contents.\r
+                * @example\r
+                * document.write(\r
+                *     '<html>' +\r
+                *         '<head><title>Sample Doc</title></head>' +\r
+                *         '<body>Document contents created by code</body>' +\r
+                *      '</html>' );\r
+                */\r
+               write : function( html )\r
+               {\r
+                       // Don't leave any history log in IE. (#5657)\r
+                       this.$.open( 'text/html', 'replace' );\r
+\r
+                       // Support for custom document.domain in IE.\r
+                       CKEDITOR.env.isCustomDomain() &&  ( this.$.domain = document.domain );\r
+\r
+                       this.$.write( html );\r
+                       this.$.close();\r
                }\r
        });\r