Description
Previously (version <= 6.0.8, but I suspect <= 6.0.11) , code like the following worked:
public void onSomething(AjaxRequestTarget target) {
target.prependJavaScript(
"notify|jQuery('#someSelector').slideUp({\n" +
" complete: function()
\n" +
"});"
);
}
Note two things about this code:
- it uses the "notify|...." method to delay execution of other scripts until the animation is complete;
- it contains some new line characters.
In Wicket 6.0.12 (and 6.0.13) this script fails silently: the slideUp doesn't get executed.
When I remove the new-line-characters "\n" from the script, it works again.
Cause: line 1075 of wicket-ajax-jquery.js states:
var scriptSplitterR = new RegExp("\\(function\\(\\)
\\)\\(
);", 'gi');
This regular expression does NOT match my script, while it should. This is caused by the the dot not matching the new line character.
A solution (according to various sources) could be the following, as [\S\s] matches any character (including new line characters):
var scriptSplitterR = new RegExp("\\(function\\(\\)
\\)\\(
);", 'gi');
Additional info: on github, I see the following lines in wicket-ajax-jquery.js have changed between 6.0.11 and 6.0.12:
var scripts = cleanArray(text.split(scriptSplitterR));
has become:
var scripts = [];
var scr;
while ( (scr = scriptSplitterR.exec(text) ) != null ) {
scripts.push(scr[0]);
}
I suspect this change now causes my little problem.