Ticket #2970: 2970.patch
File 2970.patch, 5.1 KB (added by , 14 years ago) |
---|
-
_source/core/tools.js
42 42 * @param {Object} target The object to be extended. 43 43 * @param {Object} source[,souce(n)] The objects from which copy 44 44 * properties. Any number of objects can be passed to this function. 45 * @param {Boolean} [overwrite] Indicates that properties already present 46 * in the target object must be overwritten. This must be the last 47 * parameter in the function call. 45 * @param {Boolean|Array} [overwrite] If 'true' is specified it 46 * indicates that properties already present in the target 47 * object must be overwritten. If an Array of property names 48 * is specified, only names specified in the collection will 49 * be received from the source object. 50 * This must be the last parameter in the function call. 48 51 * @returns {Object} the extended object (target). 49 52 * @example 50 53 * // Create the sample object. … … 67 70 extend : function( target ) 68 71 { 69 72 var argsLength = arguments.length, 70 overwrite = arguments[ argsLength - 1 ]; 73 overwrite = arguments[ argsLength - 1 ], 74 //whether it's a to-receiving properties list 75 isList; 71 76 72 if ( typeof overwrite == 'boolean' ) 73 argsLength--; 77 if ( typeof overwrite == 'boolean' 78 || ( isList = CKEDITOR.tools.isArray( overwrite ) ) ) 79 argsLength--; 74 80 else 75 81 overwrite = false; 76 82 … … 80 86 81 87 for ( var propertyName in source ) 82 88 { 83 if ( overwrite || target[ propertyName ] == undefined ) 89 if ( ( overwrite === true || target[ propertyName ] == undefined ) 90 //only copy property in the list 91 || ( isList && CKEDITOR.tools.indexOf( overwrite, propertyName ) != -1 ) ) 84 92 target[ propertyName ] = source[ propertyName ]; 85 93 } 86 94 } -
_source/core/dom/documentFragment.js
2 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ 5 5 /** 6 * DocumentFragment is a "lightweight" or "minimal" Document object. It is 7 * commonly used to extract a portion of a document's tree or to create a new 8 * fragment of a document. Various operations may take DocumentFragment objects 9 * as arguments and results in all the child nodes of the DocumentFragment being 10 * moved to the child list of this node. 11 * 12 * @param {Object} ownerDocument 13 */ 6 14 CKEDITOR.dom.documentFragment = function( ownerDocument ) 7 15 { 8 this.$ = CKEDITOR.env.ie ? ownerDocument.$.createElement( 'div' ) : ownerDocument.$.createDocumentFragment(); 16 ownerDocument = ownerDocument || CKEDITOR.document; 17 this.$ = ownerDocument.$.createDocumentFragment(); 9 18 }; 10 19 11 (function() 12 { 13 var elementPrototype = CKEDITOR.dom.element.prototype; 14 15 CKEDITOR.dom.documentFragment.prototype = 16 { 17 type : CKEDITOR.NODE_DOCUMENT_FRAGMENT, 18 19 append : elementPrototype.append, 20 21 getFirst : elementPrototype.getFirst, 22 23 getLast : elementPrototype.getLast, 24 25 appendTo : function( targetElement ) 26 { 27 if ( CKEDITOR.env.ie ) 28 elementPrototype.moveChildren.call( this, targetElement ); 29 else 30 targetElement.$.appendChild( this.$ ); 31 }, 32 33 moveChildren : elementPrototype.moveChildren, 34 35 insertAfterNode : function( node ) 36 { 37 var $ = this.$; 38 var $node = node.$; 39 var $parent = $node.parentNode; 40 41 if ( CKEDITOR.env.ie ) 42 { 43 for ( var child ; child = $.lastChild ; ) 44 $parent.insertBefore( $.removeChild( child ), $node.nextSibling ); 45 } 46 else 47 $parent.insertBefore( $, $node.nextSibling ); 48 }, 49 50 replace : function( nodeToReplace ) 51 { 52 this.insertAfterNode( nodeToReplace ); 53 nodeToReplace.remove(); 54 }, 55 56 trim : elementPrototype.trim, 57 ltrim : elementPrototype.ltrim, 58 rtrim : elementPrototype.rtrim, 59 getFirst : elementPrototype.getFirst, 60 getLast : elementPrototype.getLast, 61 getDocument : elementPrototype.getDocument, 62 getChildCount : elementPrototype.getChildCount, 63 getChild : elementPrototype.getChild, 64 contains : elementPrototype.contains 65 }; 66 })(); 20 CKEDITOR.tools.extend( CKEDITOR.dom.documentFragment.prototype, 21 CKEDITOR.dom.element.prototype, 22 { 23 type :CKEDITOR.NODE_DOCUMENT_FRAGMENT, 24 insertAfterNode : function( node ) 25 { 26 var $ = this.$; 27 var $node = node.$; 28 var $parent = $node.parentNode; 29 $parent.insertBefore( $, $node.nextSibling ); 30 } 31 }, [ 'type', 'append', 'getFirst', 'getLast', 'appendTo', 'moveChildren', 32 'insertAfterNode', 'replace', 'trim', 'ltrim', 'rtrim', 'getFirst', 33 'getLast', 'getDocument', 'getChildCount', 'getChild', 'getChildren', 34 'contains' ] );