Fix IE8 issues

- Fix error that happens on load: 'tokens' is null or not an object
- Syntax highlighting didn't actually work due to IE8 match semantics being different (empty string, not undefined, returned unmatched capturing groups)
This commit is contained in:
Joe Cheng 2011-02-09 19:48:14 +08:00 committed by Fabian Jakobs
commit dae577b086
2 changed files with 3 additions and 2 deletions

View file

@ -227,7 +227,8 @@ var Text = function(parentEl) {
style.width = config.width + "px";
var html = [];
this.$renderLine(html, row, tokens[row-firstRow].tokens);
if (tokens.length > row-firstRow)
this.$renderLine(html, row, tokens[row-firstRow].tokens);
// don't use setInnerHtml since we are working with an empty DIV
lineEl.innerHTML = html.join("");
fragment.appendChild(lineEl);

View file

@ -79,7 +79,7 @@ var Tokenizer = function(rules) {
}
for ( var i = 0; i < state.length; i++) {
if (match[i + 1] !== undefined) {
if (match[i + 1] !== undefined && match[i + 1].length) {
if (typeof state[i].token == "function") {
type = state[i].token(match[0]);
}