From dae577b086d638534e5eff5f9f4d9bf18af90bb8 Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Wed, 9 Feb 2011 19:48:14 +0800 Subject: [PATCH] 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) --- lib/ace/layer/text.js | 3 ++- lib/ace/tokenizer.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js index a4af26bb..b6cb25e0 100644 --- a/lib/ace/layer/text.js +++ b/lib/ace/layer/text.js @@ -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); diff --git a/lib/ace/tokenizer.js b/lib/ace/tokenizer.js index 1bd8ab5d..50861df5 100644 --- a/lib/ace/tokenizer.js +++ b/lib/ace/tokenizer.js @@ -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]); }