﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
8659	SCAYT + SyntaxHighlighter conflict	Anna Tomanek		"As reported in: http://cksource.com/forums/viewtopic.php?f=11&t=24453

'''Problem:'''[[BR]]
On a page which uses Alex Gorbatchev's SyntaxHighlighter and has a CKEditor instance with SCAYT enabled, a script error is thrown when pasting into the editor.

In Firefox, the error is similar to: ""e is undefined"", shCore.js line 17.[[BR]]
In IE, the error is similar to ""Unable to get value of the property 'valueOf': object is null or undefined"", http://svc.webspellchecker.net/scayt26/_base.xd.js, line 3268.

'''Cause:'''[[BR]]
SyntaxHighlighter uses the XRegExp library, which replaces the native String.prototype.replace(search, replacement) function. SCAYT seems to call the replace function without passing the replacement parameter. The new replace function attempts to call valueOf on the replacement parameter, which throws the error.

This appears to be a bug in SCAYT; however, the native replace function will convert an undefined parameter to the string ""undefined"", which would mask this problem.


'''Workaround:'''[[BR]]
Override the new replace function to cope with an undefined replacement parameter:
{{{
    jQuery(function(){
        var oldReplace = String.prototype.replace;
        String.prototype.replace = function (search, replacement) {
            if (""undefined"" === typeof(replacement)) { replacement = """"; }
            return oldReplace.call(this, search, replacement);
        };
    });
}}}

The affected line in the SCAYT code is:
{{{
    if(node.nodeName.match(t.nextNode.blockElementsRegex)
    &&this.text.replace(/\s/).length!=""""){
}}}

This should be:
{{{
    if(node.nodeName.match(t.nextNode.blockElementsRegex)
    &&this.text.replace(/\s/,"""").length!=0){
}}}

"	Bug	closed	Normal		UI : Spell Checker	3.0	fixed		WebSpellChecker.net
