From: Alan Knowles Date: Thu, 4 Aug 2011 07:04:54 +0000 (+0000) Subject: Prefer substring to using index for string tests X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=e8746406456e11600ccc847aaed43cefcb884e0c Prefer substring to using index for string tests --- diff --git a/Roo/XComponent.js b/Roo/XComponent.js index 37b7bdae82..749fd3c563 100644 --- a/Roo/XComponent.js +++ b/Roo/XComponent.js @@ -131,7 +131,7 @@ Roo.extend(Roo.XComponent, Roo.util.Observable, { el = el || false; var hp = this.parent ? 1 : 0; - if (!el && typeof(this.parent) == 'string' && this.parent[0] == '#') { + if (!el && typeof(this.parent) == 'string' && this.parent.substring(0,1) == '#') { // if parent is a '#.....' string, then let's use that.. var ename = this.parent.substr(1) this.parent = false; @@ -248,7 +248,7 @@ Roo.apply(Roo.XComponent, { if (!str || typeof(str) == 'object') { return str; } - if (str[0]=='#') { + if (str.substring(0,1) == '#') { return str; } diff --git a/roojs-all.js b/roojs-all.js index 361cb2ab5a..35c44012f6 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -957,8 +957,8 @@ Roo.XTemplate=function(){Roo.XTemplate.superclass.constructor.apply(this,argumen D.push({id:id,target:G,exec:F,test:fn,body:m[1]||''});s=s.replace(m[0],'{xtpl'+id+'}');++id;}for(var i=D.length-1;i>=0;--i){this.compileTpl(D[i]);} this.master=D[D.length-1];this.tpls=D;};Roo.extend(Roo.XTemplate,Roo.Template,{re:/\{([\w-\.]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,applySubTemplate:function(id,A,B){var t=this.tpls[id];if(t.test&&!t.test.call(this,A,B)){return '';}if(t.exec&&t.exec.call(this,A,B)){return '';}var vs=t.target?t.target.call(this,A,B):A;B=t.target?A:B;if(t.target&&vs instanceof Array){var C=[];for(var i=0,D=vs.length;iString(b).toUpperCase()?1:-1;};if((!this.topModule||!this.topModule.modules)&&!this.elmodules.length){throw "No top level modules to build";}var C=this.topModule?[this.topModule]:[];Roo.each(this.elmodules,function(e){C.push(e)});var D=function(m){C.push(m);if(m.modules){m.modules.keySort('ASC',B);m.modules.each(D);}if(m.finalize){m.finalize.name=m.name+" (clean up) ";C.push(m.finalize);}};if(this.topModule){this.topModule.modules.keySort('ASC',B);this.topModule.modules.each(D);}return C;},build:function(){this.preBuild();var A=this.buildOrder();if(!A.length){throw "NO modules!!!";} diff --git a/roojs-debug.js b/roojs-debug.js index c9e0eed314..3f5fb5a511 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -51449,7 +51449,7 @@ Roo.extend(Roo.XComponent, Roo.util.Observable, { el = el || false; var hp = this.parent ? 1 : 0; - if (!el && typeof(this.parent) == 'string' && this.parent[0] == '#') { + if (!el && typeof(this.parent) == 'string' && this.parent.substring(0,1) == '#') { // if parent is a '#.....' string, then let's use that.. var ename = this.parent.substr(1) this.parent = false; @@ -51566,7 +51566,7 @@ Roo.apply(Roo.XComponent, { if (!str || typeof(str) == 'object') { return str; } - if (str[0]=='#') { + if (str.substring(0,1) == '#') { return str; } diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index bcba846501..4e906d41f2 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -36989,7 +36989,7 @@ Roo.extend(Roo.XComponent, Roo.util.Observable, { el = el || false; var hp = this.parent ? 1 : 0; - if (!el && typeof(this.parent) == 'string' && this.parent[0] == '#') { + if (!el && typeof(this.parent) == 'string' && this.parent.substring(0,1) == '#') { // if parent is a '#.....' string, then let's use that.. var ename = this.parent.substr(1) this.parent = false; @@ -37106,7 +37106,7 @@ Roo.apply(Roo.XComponent, { if (!str || typeof(str) == 'object') { return str; } - if (str[0]=='#') { + if (str.substring(0,1) == '#') { return str; } diff --git a/roojs-ui.js b/roojs-ui.js index 4917e52c7b..8b6fa9646d 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -713,8 +713,8 @@ Roo.XTemplate=function(){Roo.XTemplate.superclass.constructor.apply(this,argumen D.push({id:id,target:G,exec:F,test:fn,body:m[1]||''});s=s.replace(m[0],'{xtpl'+id+'}');++id;}for(var i=D.length-1;i>=0;--i){this.compileTpl(D[i]);} this.master=D[D.length-1];this.tpls=D;};Roo.extend(Roo.XTemplate,Roo.Template,{re:/\{([\w-\.]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,applySubTemplate:function(id,A,B){var t=this.tpls[id];if(t.test&&!t.test.call(this,A,B)){return '';}if(t.exec&&t.exec.call(this,A,B)){return '';}var vs=t.target?t.target.call(this,A,B):A;B=t.target?A:B;if(t.target&&vs instanceof Array){var C=[];for(var i=0,D=vs.length;iString(b).toUpperCase()?1:-1;};if((!this.topModule||!this.topModule.modules)&&!this.elmodules.length){throw "No top level modules to build";}var C=this.topModule?[this.topModule]:[];Roo.each(this.elmodules,function(e){C.push(e)});var D=function(m){C.push(m);if(m.modules){m.modules.keySort('ASC',B);m.modules.each(D);}if(m.finalize){m.finalize.name=m.name+" (clean up) ";C.push(m.finalize);}};if(this.topModule){this.topModule.modules.keySort('ASC',B);this.topModule.modules.each(D);}return C;},build:function(){this.preBuild();var A=this.buildOrder();if(!A.length){throw "NO modules!!!";}