javierdotnet / gwt-ext

Automatically exported from code.google.com/p/gwt-ext
0 stars 3 forks source link

In TextField insertAtCaret has a bug in IE7 #411

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a textfield
2. Use the method insertAtCaret and try to insert the string * 

The IE7 throws an error (Unexpected Qualifier).
It's just because the code (623 to 628): 
  for (var index = 0, start = 0; tmp.match(text) && ((tmp =
tmp.replace(text, '')) && index <= diff); index = start + text.length) {

The variable text must be escaped before doing a match or replace  if it's
one of these: \ ( ) * ? + . [ ] 

To match or replace work these character must be \\ \( \) \* \? \+ \. \[ \]

Original issue reported on code.google.com by bozo...@gmail.com on 11 Sep 2008 at 5:05

GoogleCodeExporter commented 9 years ago
I build de fix 

chage the lines:
for(var index = 0, start = 0; 
                tmp.match(macthTxt) 
                    && (tmp = tmp.replace(macthTxt, "")) 
                    && index <= diff; 
                index = start + text.length
            )

To:

            var macthTxt;
            if ((text == "\\") || (text == "(") || 
               (text == ")") || (text == "*") || 
               (text == "?") || (text == "+") || 
               (text == ".") || (text == "[") || 
               (text == "]")) 
            {
                macthTxt="\\"+text;
            } else {
                macthTxt=text
            }
            for(var index = 0, start = 0; 
                tmp.match(macthTxt) 
                    && (tmp = tmp.replace(macthTxt, "")) 
                    && index <= diff; 
                index = start + text.length
            )

I had attache de fixed TextField File

Original comment by bozo...@gmail.com on 11 Sep 2008 at 8:58

Attachments:

GoogleCodeExporter commented 9 years ago
Added code to SVN.

Original comment by mlim1...@gmail.com on 18 Sep 2008 at 4:47