views:

91

answers:

1

Hi all. I have a jquery plugin that is working on all browsers, except opera. The removeHighlight function gets triggered, but the html is not changed. As far as I can see IE, FF, Chrome and Safari work as expected.

My example can be found here: http://www.pritaeas.net/public/jquery/plugin-dev/

The plugin's url is: http://www.pritaeas.net/public/jquery/plugin-dev/jquery.highlight.js

Basically, I just want to remove all span tags with a specific class, leaving the text as-is.

Can anyone explain why opera is responding differently, and provide a solution or work-around ?

Thanks.

A: 

Problem is in your removeHighlight function, in regex. I don't know why, but your regex doesn't work if it is in form:

var source = new RegExp("<span class=.?" + options["cssClass"] + ".?>(.*?)</span>", "ig");

especially first .? is problematic in this case. When you change it to . or \", then your regex works great. You can use \" form, as in correctly formatted html all attributes should be enclosed in parenthesis, and you can add them in highlight function too:

var target = "<span class=\"" + options["cssClass"] + "\">%&</span>";
MBO
I tried that, but in IE apparantly jQuery does not add the quotes. So I decided for no/one character before and after. For what reason would .? be problematic ?
pritaeas
I think \"? does the trick. Still. Can anyone tell me why the .? is ineffective here ?
pritaeas
I think it's a bug, I submited it to Opera and we'll see what they will say about it'
MBO
Thanks MBO, found the bug report (for the record it's now tracked as CORE-26329) and will push it towards a fix.
hallvors