阅读:2837回复:4
关于本论坛代码语法高亮功能
除IE 和 Edge 外, Firefox 和 Chrome 浏览本论坛的代码语法高亮都不正常。
Firefox 的 webconsole 中提示 TypeError: RegExp exec method should return object or null shCore.js:94:41 Chrome 的 Uncaught TypeError: RegExp exec method returned something other than an Object or null 两个浏览器都指向 https://www.firefox.net.cn/res/js/dev/windeditor/plugins/insertCode/syntaxHihglighter/scripts/shCore.js?v=20140228 脚本的一个错误。 我尝试将本含有代码高亮的页面“另存为”, 并将 shCore.js 脚本中 的290行 if(!str) { return; } 改为 if(!str) { return null; } 结果在本地能成功地修复这个问题。 希望管理员试试这个方法,看能否修复。@fiag Test: --- .\shCore.js 2018-04-29 19:32:55.000000000 +0800 +++ .\shCore.js 2018-04-29 19:40:01.000000000 +0800 @@ -284,13 +284,13 @@ // Adds named capture support (with backreferences returned as `result.name`), and fixes two // cross-browser issues per ES3: // - Captured values for nonparticipating capturing groups should be returned as `undefined`, // rather than the empty string. // - `lastIndex` should not be incremented after zero-length matches. RegExp.prototype.exec = function (str) { - if(!str) { return; } + if(!str) { return null; } var match = real.exec.apply(this, arguments), name, r2; if (match) { // Fix browsers whose `exec` methods don't consistently return `undefined` for // nonparticipating capturing groups if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) { |
|
1楼#
发布于:2018-04-29 20:30
|
|
2楼#
发布于:2018-05-02 22:59
diff 已合并。
![]() |
|
3楼#
发布于:2018-05-03 00:50
|
|
4楼#
发布于:2018-05-05 08:11
|
|