comparison default/node_modules/shoestring/src/dom/html.js @ 0:1d038bc9b3d2 default tip

Up:default
author Liny <dev@neowd.com>
date Sat, 31 May 2025 09:21:51 +0800
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1d038bc9b3d2
1 //>>excludeStart("exclude", pragmas.exclude);
2 define([ "shoestring" ], function(){
3 //>>excludeEnd("exclude");
4
5 var set = function( html ){
6 if( typeof html === "string" || typeof html === "number" ){
7 return this.each(function(){
8 this.innerHTML = "" + html;
9 });
10 } else {
11 var h = "";
12 if( typeof html.length !== "undefined" ){
13 for( var i = 0, l = html.length; i < l; i++ ){
14 h += html[i].outerHTML;
15 }
16 } else {
17 h = html.outerHTML;
18 }
19 return this.each(function(){
20 this.innerHTML = h;
21 });
22 }
23 };
24 /**
25 * Gets or sets the `innerHTML` from all the elements in the set.
26 *
27 * @param {string|undefined} html The html to assign
28 * @return {string|shoestring}
29 * @this shoestring
30 */
31 shoestring.fn.html = function( html ){
32 //>>includeStart("development", pragmas.development);
33 if( !!html && typeof html === "function" ){
34 shoestring.error( 'html-function' );
35 }
36 //>>includeEnd("development");
37 if( typeof html !== "undefined" ){
38 return set.call( this, html );
39 } else { // get
40 var pile = "";
41
42 this.each(function(){
43 pile += this.innerHTML;
44 });
45
46 return pile;
47 }
48 };
49
50 //>>excludeStart("exclude", pragmas.exclude);
51 });
52 //>>excludeEnd("exclude");