Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: "Regular expression too complex" when using Mozilla Firefox 4

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #11
    Sencha User
    Join Date
    Mar 2007
    Posts
    448

    Default

    Actually, I take it back -- the fix worked in some cases, but as the HTML got more complex, I started getting the same error.

  2. #12
    Sencha User
    Join Date
    Mar 2007
    Posts
    448

    Default

    I opened a bug with Firefox.

  3. #13
    Sencha User
    Join Date
    Mar 2007
    Posts
    448

    Default

    Here's my workaround. It's not pretty, but it does the job. This is based on the ExtJS 2.2.1 Element.js code. If you compare it against that version, you can see the differences, and they should be pretty easy to apply to other versions.

    Code:
    Ext.override(Ext.Element, {
    	update : function(html, loadScripts, callback){
    		if(typeof html == "undefined"){
    			html = "";
    		}
    		if(loadScripts !== true){
    			this.dom.innerHTML = html;
    			if(typeof callback == "function"){
    				callback();
    			}
    			return this;
    		}
    		var id = Ext.id();
    		var dom = this.dom;
    
    		html += '<span id="' + id + '"></span>';
    
    		var tokenizeScripts = function(str) {
    			var result = {
    				scripts:[],
    				other:[]
    			};
    			var outIdx = 0;
    			var matchStart, matchEnd, token;
    			var reStart = /<script.*?>/ig;
    			var reEnd = /<\/script>/ig;
    			while (matchStart = reStart.exec(str)) {
    				token = str.substring(outIdx, reStart.lastIndex - matchStart[0].length);
    				if (token.length > 0) result.other.push(token);
    				reEnd.lastIndex = reStart.lastIndex;
    				if (matchEnd = reEnd.exec(str)) {
    					var endIndex = reEnd.lastIndex - matchEnd[0].length;
    					token = str.substring(reStart.lastIndex, endIndex);
    					result.scripts.push([matchStart[0], token]);
    					reStart.lastIndex = reEnd.lastIndex;
    					outIdx = reEnd.lastIndex;
    				}
    			}
    			token = str.substring(outIdx);
    			if (token.length > 0) result.other.push(token);
    			return result;
    		};
    
    		Ext.lib.Event.onAvailable(id, function(){
    			var hd = document.getElementsByTagName("head")[0];
    			var srcRe = /\ssrc=([\'\"])(.*?)\1/i;
    			var typeRe = /\stype=([\'\"])(.*?)\1/i;
    
    			var tokens = tokenizeScripts(html);
    			for (var i = 0; i < tokens.scripts.length; i++) {
    				var start = tokens.scripts[i][0];
    				var content = tokens.scripts[i][1];
    				var srcMatch = start ? start.match(srcRe) : false;
    				if(srcMatch && srcMatch[2]){
    					var s = document.createElement("script");
    					s.src = srcMatch[2];
    					var typeMatch = start.match(typeRe);
    					if(typeMatch && typeMatch[2]){
    						s.type = typeMatch[2];
    					}
    					hd.appendChild(s);
    				}else if(content && content.length > 0){
    					if(window.execScript) {
    						window.execScript(content);
    					} else {
    						window.eval(content);
    					}
    				}
    			}
    			var el = document.getElementById(id);
    			if(el){Ext.removeNode(el);}
    			if(typeof callback == "function"){
    				callback();
    			}
    		});
    		var tokens = tokenizeScripts(html);
    		dom.innerHTML = tokens.other.join('');
    		return this;
    	}
    });

  4. #14
    Ext JS Premium Member stevil's Avatar
    Join Date
    Nov 2007
    Location
    Denver, CO
    Posts
    1,045

    Default

    @jweber,

    My solution for Ext JS 4 (because it's just different enough that I can't apply your patch directly):

    http://www.sencha.com/forum/showthre...302#post619302

    thanks,

    stevil

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Grid/XML problem - "unterminated regular expression lit
    By Saeven in forum Ext 1.x: Help & Discussion
    Replies: 13
    Last Post: 10 Nov 2010, 2:58 AM
  2. [FIXED-93] "Line 32" expression "this.el" ext-complete.js
    By Shane F in forum Ext Designer: Bugs
    Replies: 12
    Last Post: 7 Apr 2010, 9:29 AM
  3. Help needed for writing regular expression for this complex conditions
    By atuldige in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 14 Nov 2009, 2:15 AM
  4. BorderLayout on a div inside a "regular" page
    By digeomel in forum Ext 1.x: Help & Discussion
    Replies: 6
    Last Post: 28 Feb 2007, 6:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •