livebs / syntaxhighlighter

Automatically exported from code.google.com/p/syntaxhighlighter
GNU General Public License v3.0
0 stars 0 forks source link

JQuery prototypes on Array are skewing Array.length, causing errors in shCore.js (patch included + screenie) #153

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
from shCore.js (added extra if check for typeof == object)

        /**
        * Applies all regular expression to the code and stores all found
        * matches in the `this.matches` array.
        * @param {Array} regexList      List of regular 
expressions.
        * @param {String} code          Source code.
        * @return {Array}               Returns list of 
matches.
        */
        findMatches: function(regexList, code) {
            var result = [];

            if (regexList != null) {
                for (var i = 0; i < regexList.length; i++) {
                    // BUG: length returns len+1 for array if methods 
added to prototype chain (oising@gmail.com)
                    if (typeof (regexList[i]) == "object") {
                        result = result.concat(sh.utils.getMatches(code, 
regexList[i]));
                    }
                }
            }

            // sort the matches
            result = result.sort(sh.utils.matchesSortCallback);

            return result;
        },

Original issue reported on code.google.com by ois...@gmail.com on 4 Jun 2009 at 5:22

Attachments: