some more ie7 fixes
This commit is contained in:
parent
4b4a5d045c
commit
95f0e7308f
5 changed files with 79 additions and 36 deletions
|
|
@ -31,42 +31,76 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
var MAX_TOKEN_COUNT = 1000;
|
||||
var useragent = require("../lib/useragent")
|
||||
var TokenizerModule = require("../tokenizer")
|
||||
var useragent = require("../lib/useragent");
|
||||
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")
|
||||
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;
|
||||
if (compliantExecNpcg)
|
||||
return;
|
||||
|
||||
var proto = TokenizerModule.Tokenizer.prototype;
|
||||
eval("TokenizerModule.Tokenizer = " +
|
||||
TokenizerModule.Tokenizer.toString().replace(
|
||||
"ruleRegExps.push(adjustedregex);\n", function(m) {
|
||||
return m + '\
|
||||
if (state[i].next && RegExp(adjustedregex).test(""))\n\
|
||||
rule._qre = RegExp(adjustedregex, "g");\n\
|
||||
'
|
||||
}
|
||||
)
|
||||
TokenizerModule.Tokenizer_orig = TokenizerModule.Tokenizer;
|
||||
proto.getLineTokens_orig = proto.getLineTokens;
|
||||
|
||||
patch(
|
||||
TokenizerModule, "Tokenizer",
|
||||
"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;
|
||||
eval("proto.getLineTokens = " +
|
||||
proto.getLineTokens.toString().replace(
|
||||
/if \(match\[i \+ 1\] === undefined\)\s*continue;/,
|
||||
"if (!match[i + 1]) {\n\
|
||||
if (value)continue;\n\
|
||||
var qre = state[mapping[i]]._qre;\n\
|
||||
if (!qre) continue;\n\
|
||||
qre.lastIndex = lastIndex;\n\
|
||||
if (!qre.exec(line) || qre.lastIndex != lastIndex)\n\
|
||||
continue;\n\
|
||||
}"
|
||||
)
|
||||
patch(
|
||||
proto, "getLineTokens",
|
||||
/if \(match\[i \+ 1\] === undefined\)\s*continue;/,
|
||||
"if (!match[i + 1]) {\n\
|
||||
if (value)continue;\n\
|
||||
var qre = state[mapping[i]]._qre;\n\
|
||||
if (!qre) continue;\n\
|
||||
qre.lastIndex = lastIndex;\n\
|
||||
if (!qre.exec(line) || qre.lastIndex != lastIndex)\n\
|
||||
continue;\n\
|
||||
}"
|
||||
);
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
|
@ -51,8 +51,9 @@ module.exports = {
|
|||
}
|
||||
|
||||
try {
|
||||
// break this to emulate old ie
|
||||
RegExp.prototype.exec = brokenExec;
|
||||
require("./ie_quirks");
|
||||
require("./old_ie");
|
||||
var JavaScriptMode = require("../mode/javascript").Mode;
|
||||
var mode = new JavaScriptMode();
|
||||
var tokenizer = mode.getTokenizer();
|
||||
|
|
@ -60,7 +61,11 @@ module.exports = {
|
|||
var tokens = tokenizer.getLineTokens("'juhu'", "start").tokens;
|
||||
assert.equal("string", tokens[0].type);
|
||||
} finally {
|
||||
// restore modified functions
|
||||
RegExp.prototype.exec = exec;
|
||||
var module = require("../tokenizer");
|
||||
module.Tokenizer = module.Tokenizer_orig;
|
||||
module.Tokenizer.prototype.getLineTokens = module.Tokenizer.prototype.getLineTokens_orig;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -75,9 +75,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
|
|||
this.editor = editor;
|
||||
};
|
||||
|
||||
this.$init = function() {
|
||||
var sb = this.element;
|
||||
|
||||
this.$initElements = function(sb) {
|
||||
this.searchBox = sb.querySelector(".ace_search_form");
|
||||
this.replaceBox = sb.querySelector(".ace_replace_form");
|
||||
this.searchOptions = sb.querySelector(".ace_search_options");
|
||||
|
|
@ -86,7 +84,13 @@ var SearchBox = function(editor, range, showReplaceForm) {
|
|||
this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]");
|
||||
this.searchInput = this.searchBox.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;
|
||||
event.addListener(sb, "mousedown", function(e) {
|
||||
setTimeout(function(){
|
||||
|
|
|
|||
|
|
@ -215,18 +215,18 @@ var TextInput = function(parentNode, host) {
|
|||
if (data)
|
||||
host.onPaste(data);
|
||||
pasted = false;
|
||||
} else if (data == PLACEHOLDER[0]) {
|
||||
} else if (data == PLACEHOLDER.charAt(0)) {
|
||||
if (afterContextMenu)
|
||||
host.execCommand("del", {source: "ace"});
|
||||
} else {
|
||||
if (data.substring(0, 2) == PLACEHOLDER)
|
||||
data = data.substr(2);
|
||||
else if (data[0] == PLACEHOLDER[0])
|
||||
else if (data.charAt(0) == PLACEHOLDER.charAt(0))
|
||||
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);
|
||||
// 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);
|
||||
|
||||
if (data)
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ var HtmlHighlightRules = function() {
|
|||
token : "keyword.operator.separator",
|
||||
regex : "=",
|
||||
push : [{
|
||||
include: "space",
|
||||
include: "space"
|
||||
}, {
|
||||
token : "string",
|
||||
regex : "[^<>='\"`\\s]+",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue