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

View file

@ -79,7 +79,7 @@ var Tokenizer = function(rules) {
} }
for ( var i = 0; i < state.length; i++) { 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") { if (typeof state[i].token == "function") {
type = state[i].token(match[0]); type = state[i].token(match[0]);
} }