some more ie7 fixes

This commit is contained in:
nightwing 2013-07-30 00:22:53 +04:00
commit 95f0e7308f
5 changed files with 79 additions and 36 deletions

View file

@ -31,42 +31,76 @@
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
var MAX_TOKEN_COUNT = 1000; var MAX_TOKEN_COUNT = 1000;
var useragent = require("../lib/useragent") var useragent = require("../lib/useragent");
var TokenizerModule = require("../tokenizer") var TokenizerModule = require("../tokenizer");
function patch(obj, name, regexp, replacement) {
eval("obj['" + name + "']=" + obj[name].toString().replace(
regexp, replacement
));
console.log(obj[name]+"")
}
if (useragent.isIE && useragent.isIE < 10 && window.top.document.compatMode === "BackCompat") if (useragent.isIE && useragent.isIE < 10 && window.top.document.compatMode === "BackCompat")
useragent.isOldIE = true; useragent.isOldIE = true;
if (typeof document != "undefined" && !document.documentElement.querySelector) {
var qs = function(el, selector) {
if (selector.charAt(0) == ".") {
var classNeme = selector.slice(1);
} else {
var m = selector.match(/(\w+)=(\w+)/);
var attr = m && m[1];
var attrVal = m && m[2];
}
for (var i = 0; i < el.all.length; i++) {
var ch = el.all[i];
if (classNeme) {
if (ch.className.indexOf(classNeme) != -1)
return ch;
} else if (attr) {
if (ch.getAttribute(attr) == attrVal)
return ch;
}
}
};
var sb = require("./searchbox").SearchBox.prototype;
patch(
sb, "$initElements",
/([^\s=]*).querySelector\((".*?")\)/g,
"qs($1, $2)"
);
}
var compliantExecNpcg = /()??/.exec("")[1] === undefined; var compliantExecNpcg = /()??/.exec("")[1] === undefined;
if (compliantExecNpcg) if (compliantExecNpcg)
return; return;
var proto = TokenizerModule.Tokenizer.prototype; var proto = TokenizerModule.Tokenizer.prototype;
eval("TokenizerModule.Tokenizer = " + TokenizerModule.Tokenizer_orig = TokenizerModule.Tokenizer;
TokenizerModule.Tokenizer.toString().replace( proto.getLineTokens_orig = proto.getLineTokens;
"ruleRegExps.push(adjustedregex);\n", function(m) {
return m + '\ patch(
if (state[i].next && RegExp(adjustedregex).test(""))\n\ TokenizerModule, "Tokenizer",
rule._qre = RegExp(adjustedregex, "g");\n\ "ruleRegExps.push(adjustedregex);\n",
' function(m) {
} return m + '\
) if (state[i].next && RegExp(adjustedregex).test(""))\n\
rule._qre = RegExp(adjustedregex, "g");\n\
';
}
); );
TokenizerModule.Tokenizer.prototype = proto; TokenizerModule.Tokenizer.prototype = proto;
eval("proto.getLineTokens = " + patch(
proto.getLineTokens.toString().replace( proto, "getLineTokens",
/if \(match\[i \+ 1\] === undefined\)\s*continue;/, /if \(match\[i \+ 1\] === undefined\)\s*continue;/,
"if (!match[i + 1]) {\n\ "if (!match[i + 1]) {\n\
if (value)continue;\n\ if (value)continue;\n\
var qre = state[mapping[i]]._qre;\n\ var qre = state[mapping[i]]._qre;\n\
if (!qre) continue;\n\ if (!qre) continue;\n\
qre.lastIndex = lastIndex;\n\ qre.lastIndex = lastIndex;\n\
if (!qre.exec(line) || qre.lastIndex != lastIndex)\n\ if (!qre.exec(line) || qre.lastIndex != lastIndex)\n\
continue;\n\ continue;\n\
}" }"
)
); );
}); });

View file

@ -51,8 +51,9 @@ module.exports = {
} }
try { try {
// break this to emulate old ie
RegExp.prototype.exec = brokenExec; RegExp.prototype.exec = brokenExec;
require("./ie_quirks"); require("./old_ie");
var JavaScriptMode = require("../mode/javascript").Mode; var JavaScriptMode = require("../mode/javascript").Mode;
var mode = new JavaScriptMode(); var mode = new JavaScriptMode();
var tokenizer = mode.getTokenizer(); var tokenizer = mode.getTokenizer();
@ -60,7 +61,11 @@ module.exports = {
var tokens = tokenizer.getLineTokens("'juhu'", "start").tokens; var tokens = tokenizer.getLineTokens("'juhu'", "start").tokens;
assert.equal("string", tokens[0].type); assert.equal("string", tokens[0].type);
} finally { } finally {
// restore modified functions
RegExp.prototype.exec = exec; RegExp.prototype.exec = exec;
var module = require("../tokenizer");
module.Tokenizer = module.Tokenizer_orig;
module.Tokenizer.prototype.getLineTokens = module.Tokenizer.prototype.getLineTokens_orig;
} }
} }
}; };

View file

@ -75,9 +75,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.editor = editor; this.editor = editor;
}; };
this.$init = function() { this.$initElements = function(sb) {
var sb = this.element;
this.searchBox = sb.querySelector(".ace_search_form"); this.searchBox = sb.querySelector(".ace_search_form");
this.replaceBox = sb.querySelector(".ace_replace_form"); this.replaceBox = sb.querySelector(".ace_replace_form");
this.searchOptions = sb.querySelector(".ace_search_options"); this.searchOptions = sb.querySelector(".ace_search_options");
@ -86,7 +84,13 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]"); this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]");
this.searchInput = this.searchBox.querySelector(".ace_search_field"); this.searchInput = this.searchBox.querySelector(".ace_search_field");
this.replaceInput = this.replaceBox.querySelector(".ace_search_field"); this.replaceInput = this.replaceBox.querySelector(".ace_search_field");
};
this.$init = function() {
var sb = this.element;
this.$initElements(sb);
var _this = this; var _this = this;
event.addListener(sb, "mousedown", function(e) { event.addListener(sb, "mousedown", function(e) {
setTimeout(function(){ setTimeout(function(){

View file

@ -215,18 +215,18 @@ var TextInput = function(parentNode, host) {
if (data) if (data)
host.onPaste(data); host.onPaste(data);
pasted = false; pasted = false;
} else if (data == PLACEHOLDER[0]) { } else if (data == PLACEHOLDER.charAt(0)) {
if (afterContextMenu) if (afterContextMenu)
host.execCommand("del", {source: "ace"}); host.execCommand("del", {source: "ace"});
} else { } else {
if (data.substring(0, 2) == PLACEHOLDER) if (data.substring(0, 2) == PLACEHOLDER)
data = data.substr(2); data = data.substr(2);
else if (data[0] == PLACEHOLDER[0]) else if (data.charAt(0) == PLACEHOLDER.charAt(0))
data = data.substr(1); data = data.substr(1);
else if (data[data.length - 1] == PLACEHOLDER[0]) else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
data = data.slice(0, -1); data = data.slice(0, -1);
// can happen if undo in textarea isn't stopped // can happen if undo in textarea isn't stopped
if (data[data.length - 1] == PLACEHOLDER[0]) if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
data = data.slice(0, -1); data = data.slice(0, -1);
if (data) if (data)

View file

@ -69,7 +69,7 @@ var HtmlHighlightRules = function() {
token : "keyword.operator.separator", token : "keyword.operator.separator",
regex : "=", regex : "=",
push : [{ push : [{
include: "space", include: "space"
}, { }, {
token : "string", token : "string",
regex : "[^<>='\"`\\s]+", regex : "[^<>='\"`\\s]+",