[Pkg-javascript-commits] [dojo] 06/21: reformat file to be more AMD-ish, refs #13101 also fixes a few doc references to dojo.place() (cherry picked from commit f7f44ef2152f3fa3aac131ad267763e74fbb84d0)

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 17:39:53 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag 1.9.2
in repository dojo.

commit 0b4519832d9c4ae75a2afd626b2a6f4c9141f1f5
Author: Bill Keese <bill at dojotoolkit.org>
Date:   Sat Sep 28 11:47:48 2013 +0900

    reformat file to be more AMD-ish, refs #13101
    also fixes a few doc references to dojo.place()
    (cherry picked from commit f7f44ef2152f3fa3aac131ad267763e74fbb84d0)
---
 html.js | 151 ++++++++++++++++++++++++++++++----------------------------------
 1 file changed, 71 insertions(+), 80 deletions(-)

diff --git a/html.js b/html.js
index 4befd8f..56c4e5d 100644
--- a/html.js
+++ b/html.js
@@ -3,74 +3,63 @@ define(["./_base/kernel", "./_base/lang", "./_base/array", "./_base/declare", ".
 	// module:
 	//		dojo/html
 
-	var html = {
-		// summary:
-		//		TODOC
-	};
-	lang.setObject("dojo.html", html);
-
 	// the parser might be needed..
 
 	// idCounter is incremented with each instantiation to allow assignment of a unique id for tracking, logging purposes
 	var idCounter = 0;
 
-	html._secureForInnerHtml = function(/*String*/ cont){
+	var html = {
 		// summary:
-		//		removes !DOCTYPE and title elements from the html string.
-		//
-		//		khtml is picky about dom faults, you can't attach a style or `<title>` node as child of body
-		//		must go into head, so we need to cut out those tags
-		// cont:
-		//		An html string for insertion into the dom
-		//
-		return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String
-	};
+		//		TODOC
 
-	html._emptyNode = domConstruct.empty;
-	/*=====
-	 dojo.html._emptyNode = function(node){
-		 // summary:
-		 //		Removes all child nodes from the given node.   Deprecated, should use dojo/dom-constuct.empty() directly
-		 //		instead.
-		 // node: DOMNode
-		 //		the parent element
-	 };
-	 =====*/
-
-		html._setNodeContent = function(/*DomNode*/ node, /*String|DomNode|NodeList*/ cont){
-		// summary:
-		//		inserts the given content into the given node
-		// node:
-		//		the parent element
-		// content:
-		//		the content to be set on the parent element.
-		//		This can be an html string, a node reference or a NodeList, dojo/NodeList, Array or other enumerable list of nodes
-
-		// always empty
-		domConstruct.empty(node);
-
-		if(cont){
-			if(typeof cont == "string"){
-				cont = domConstruct.toDom(cont, node.ownerDocument);
-			}
-			if(!cont.nodeType && lang.isArrayLike(cont)){
-				// handle as enumerable, but it may shrink as we enumerate it
-				for(var startlen=cont.length, i=0; i<cont.length; i=startlen==cont.length ? i+1 : 0){
-					domConstruct.place( cont[i], node, "last");
+		_secureForInnerHtml: function(/*String*/ cont){
+			// summary:
+			//		removes !DOCTYPE and title elements from the html string.
+			//
+			//		khtml is picky about dom faults, you can't attach a style or `<title>` node as child of body
+			//		must go into head, so we need to cut out those tags
+			// cont:
+			//		An html string for insertion into the dom
+			//
+			return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String
+		},
+
+		// Deprecated, should use dojo/dom-constuct.empty() directly, remove in 2.0.
+		_emptyNode: domConstruct.empty,
+
+		_setNodeContent: function(/*DomNode*/ node, /*String|DomNode|NodeList*/ cont){
+			// summary:
+			//		inserts the given content into the given node
+			// node:
+			//		the parent element
+			// content:
+			//		the content to be set on the parent element.
+			//		This can be an html string, a node reference or a NodeList, dojo/NodeList, Array or other enumerable list of nodes
+
+			// always empty
+			domConstruct.empty(node);
+
+			if(cont){
+				if(typeof cont == "string"){
+					cont = domConstruct.toDom(cont, node.ownerDocument);
+				}
+				if(!cont.nodeType && lang.isArrayLike(cont)){
+					// handle as enumerable, but it may shrink as we enumerate it
+					for(var startlen=cont.length, i=0; i<cont.length; i=startlen==cont.length ? i+1 : 0){
+						domConstruct.place( cont[i], node, "last");
+					}
+				}else{
+					// pass nodes, documentFragments and unknowns through to dojo.place
+					domConstruct.place(cont, node, "last");
 				}
-			}else{
-				// pass nodes, documentFragments and unknowns through to dojo.place
-				domConstruct.place(cont, node, "last");
 			}
-		}
 
-		// return DomNode
-		return node;
-	};
+			// return DomNode
+			return node;
+		},
 
-	// we wrap up the content-setting operation in a object
-	html._ContentSetter = declare("dojo.html._ContentSetter", null,
-		{
+		// we wrap up the content-setting operation in a object
+		_ContentSetter: declare("dojo.html._ContentSetter", null, {
 			// node: DomNode|String
 			//		An node which will be the parent element that we set content into
 			node: "",
@@ -188,7 +177,7 @@ define(["./_base/kernel", "./_base/lang", "./_base/array", "./_base/declare", ".
 			empty: function(){
 				// summary:
 				//		cleanly empty out existing content
-				
+
 				// If there is a parse in progress, cancel it.
 				if(this.parseDeferred){
 					if(!this.parseDeferred.isResolved()){
@@ -309,10 +298,10 @@ define(["./_base/kernel", "./_base/lang", "./_base/array", "./_base/declare", ".
 						inherited: inherited,
 						scope: this.parserScope
 					}).then(function(results){
-						return self.parseResults = results;
-					}, function(e){
-						self._onError('Content', e, "Error parsing in _ContentSetter#" + this.id);
-					});
+							return self.parseResults = results;
+						}, function(e){
+							self._onError('Content', e, "Error parsing in _ContentSetter#" + this.id);
+						});
 				}catch(e){
 					this._onError('Content', e, "Error parsing in _ContentSetter#" + this.id);
 				}
@@ -329,17 +318,17 @@ define(["./_base/kernel", "./_base/lang", "./_base/array", "./_base/declare", ".
 					html._setNodeContent(this.node, errText, true);
 				}
 			}
-	}); // end declare()
+		}), // end declare()
 
-	html.set = function(/*DomNode*/ node, /*String|DomNode|NodeList*/ cont, /*Object?*/ params){
+		set: function(/*DomNode*/ node, /*String|DomNode|NodeList*/ cont, /*Object?*/ params){
 			// summary:
-			//		inserts (replaces) the given content into the given node. dojo.place(cont, node, "only")
+			//		inserts (replaces) the given content into the given node. dojo/dom-construct.place(cont, node, "only")
 			//		may be a better choice for simple HTML insertion.
 			// description:
 			//		Unless you need to use the params capabilities of this method, you should use
-			//		dojo.place(cont, node, "only"). dojo.place() has more robust support for injecting
+			//		dojo/dom-construct..place(cont, node, "only"). dojo/dom-construct..place() has more robust support for injecting
 			//		an HTML string into the DOM, but it only handles inserting an HTML string as DOM
-			//		elements, or inserting a DOM node. dojo.place does not handle NodeList insertions
+			//		elements, or inserting a DOM node. dojo/dom-construct..place does not handle NodeList insertions
 			//		or the other capabilities as defined by the params object for this method.
 			// node:
 			//		the parent element that will receive the content
@@ -354,23 +343,25 @@ define(["./_base/kernel", "./_base/lang", "./_base/array", "./_base/declare", ".
 			//	|	html.set(node, "some string");
 			//	|	html.set(node, contentNode, {options});
 			//	|	html.set(node, myNode.childNodes, {options});
-		if(undefined == cont){
-			console.warn("dojo.html.set: no cont argument provided, using empty string");
-			cont = "";
-		}
-		if(!params){
-			// simple and fast
-			return html._setNodeContent(node, cont, true);
-		}else{
-			// more options but slower
-			// note the arguments are reversed in order, to match the convention for instantiation via the parser
-			var op = new html._ContentSetter(lang.mixin(
+			if(undefined == cont){
+				console.warn("dojo.html.set: no cont argument provided, using empty string");
+				cont = "";
+			}
+			if(!params){
+				// simple and fast
+				return html._setNodeContent(node, cont, true);
+			}else{
+				// more options but slower
+				// note the arguments are reversed in order, to match the convention for instantiation via the parser
+				var op = new html._ContentSetter(lang.mixin(
 					params,
 					{ content: cont, node: node }
-			));
-			return op.set();
+				));
+				return op.set();
+			}
 		}
 	};
+	lang.setObject("dojo.html", html);
 
 	return html;
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list