mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
fix(es/minifier): Remove wrong optimization of new RegExp(…)
(#7091)
This commit is contained in:
parent
8902741084
commit
493a4f7042
@ -16,6 +16,46 @@ use crate::compress::{
|
||||
pure::strings::{convert_str_value_to_tpl_cooked, convert_str_value_to_tpl_raw},
|
||||
util::is_pure_undefined,
|
||||
};
|
||||
|
||||
fn is_definitely_string(expr: &Expr) -> bool {
|
||||
match expr {
|
||||
Expr::Lit(Lit::Str(_)) => true,
|
||||
Expr::Tpl(_) => true,
|
||||
Expr::Bin(BinExpr {
|
||||
op: BinaryOp::Add,
|
||||
left,
|
||||
right,
|
||||
..
|
||||
}) => is_definitely_string(left) || is_definitely_string(right),
|
||||
Expr::Paren(ParenExpr { expr, .. }) => is_definitely_string(expr),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Check whether we can compress `new RegExp(…)` to `RegExp(…)`. That's sound
|
||||
/// unless the first argument is already a RegExp object and the second is
|
||||
/// undefined. We check for the common case where we can prove one of the first
|
||||
/// two arguments is a string.
|
||||
fn can_compress_new_regexp(args: Option<&[ExprOrSpread]>) -> bool {
|
||||
if let Some(args) = args {
|
||||
if let Some(first) = args.first() {
|
||||
if first.spread.is_some() {
|
||||
false
|
||||
} else if is_definitely_string(&first.expr) {
|
||||
true
|
||||
} else if let Some(second) = args.get(1) {
|
||||
second.spread.is_none() && is_definitely_string(&second.expr)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
true
|
||||
}
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl Pure<'_> {
|
||||
pub(super) fn remove_invalid(&mut self, e: &mut Expr) {
|
||||
match e {
|
||||
@ -555,8 +595,6 @@ impl Pure<'_> {
|
||||
"Array",
|
||||
// https://262.ecma-international.org/12.0/#sec-function-constructor
|
||||
"Function",
|
||||
// https://262.ecma-international.org/12.0/#sec-regexp-constructor
|
||||
"RegExp",
|
||||
// https://262.ecma-international.org/12.0/#sec-error-constructor
|
||||
"Error",
|
||||
// https://262.ecma-international.org/12.0/#sec-aggregate-error-constructor
|
||||
@ -569,7 +607,8 @@ impl Pure<'_> {
|
||||
"TypeError",
|
||||
"URIError",
|
||||
],
|
||||
) =>
|
||||
) || (callee.is_global_ref_to(&self.expr_ctx, "RegExp")
|
||||
&& can_compress_new_regexp(args.as_deref())) =>
|
||||
{
|
||||
self.changed = true;
|
||||
report_change!(
|
||||
|
@ -40811,7 +40811,7 @@
|
||||
'<>': 'ne'
|
||||
}, RegExpEvaluator = function() {
|
||||
function RegExpEvaluator(rVal) {
|
||||
null == (this._condVal = isString(rVal) ? RegExp(rVal) : isRegExp(rVal) ? rVal : null) && throwError(makePrintable('Illegal regexp', rVal, 'in'));
|
||||
null == (this._condVal = isString(rVal) ? new RegExp(rVal) : isRegExp(rVal) ? rVal : null) && throwError(makePrintable('Illegal regexp', rVal, 'in'));
|
||||
}
|
||||
return RegExpEvaluator.prototype.evaluate = function(lVal) {
|
||||
var type = typeof lVal;
|
||||
|
@ -153,7 +153,7 @@
|
||||
}, hasOwn = {}.hasOwnProperty, arr = [], pop = arr.pop, pushNative = arr.push, push = arr.push, slice = arr.slice, indexOf = function(list, elem) {
|
||||
for(var i = 0, len = list.length; i < len; i++)if (list[i] === elem) return i;
|
||||
return -1;
|
||||
}, booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", whitespace = "[\\x20\\t\\r\\n\\f]", identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + "*([*^$|!~]?=)" + whitespace + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + "*\\]", pseudos = ":(" + identifier + ")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|.*)\\)|)", rwhitespace = RegExp(whitespace + "+", "g"), rtrim = RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"), rcomma = RegExp("^" + whitespace + "*," + whitespace + "*"), rcombinators = RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*"), rdescend = RegExp(whitespace + "|>"), rpseudo = RegExp(pseudos), ridentifier = RegExp("^" + identifier + "$"), matchExpr = {
|
||||
}, booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", whitespace = "[\\x20\\t\\r\\n\\f]", identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + "*([*^$|!~]?=)" + whitespace + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + "*\\]", pseudos = ":(" + identifier + ")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|.*)\\)|)", rwhitespace = RegExp(whitespace + "+", "g"), rtrim = RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"), rcomma = RegExp("^" + whitespace + "*," + whitespace + "*"), rcombinators = RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*"), rdescend = RegExp(whitespace + "|>"), rpseudo = new RegExp(pseudos), ridentifier = RegExp("^" + identifier + "$"), matchExpr = {
|
||||
ID: RegExp("^#(" + identifier + ")"),
|
||||
CLASS: RegExp("^\\.(" + identifier + ")"),
|
||||
TAG: RegExp("^(" + identifier + "|[*])"),
|
||||
@ -327,7 +327,7 @@
|
||||
input.setAttribute("type", "hidden"), el.appendChild(input).setAttribute("name", "D"), el.querySelectorAll("[name=d]").length && rbuggyQSA.push("name" + whitespace + "*[*^$|!~]?="), 2 !== el.querySelectorAll(":enabled").length && rbuggyQSA.push(":enabled", ":disabled"), docElem.appendChild(el).disabled = !0, 2 !== el.querySelectorAll(":disabled").length && rbuggyQSA.push(":enabled", ":disabled"), el.querySelectorAll("*,:x"), rbuggyQSA.push(",.*:");
|
||||
})), (support.matchesSelector = rnative.test(matches = docElem.matches || docElem.webkitMatchesSelector || docElem.mozMatchesSelector || docElem.oMatchesSelector || docElem.msMatchesSelector)) && assert(function(el) {
|
||||
support.disconnectedMatch = matches.call(el, "*"), matches.call(el, "[s!='']:x"), rbuggyMatches.push("!=", pseudos);
|
||||
}), rbuggyQSA = rbuggyQSA.length && RegExp(rbuggyQSA.join("|")), rbuggyMatches = rbuggyMatches.length && RegExp(rbuggyMatches.join("|")), contains = (hasCompare = rnative.test(docElem.compareDocumentPosition)) || rnative.test(docElem.contains) ? function(a, b) {
|
||||
}), rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|")), rbuggyMatches = rbuggyMatches.length && new RegExp(rbuggyMatches.join("|")), contains = (hasCompare = rnative.test(docElem.compareDocumentPosition)) || rnative.test(docElem.contains) ? function(a, b) {
|
||||
var adown = 9 === a.nodeType ? a.documentElement : a, bup = b && b.parentNode;
|
||||
return a === bup || !!(bup && 1 === bup.nodeType && (adown.contains ? adown.contains(bup) : a.compareDocumentPosition && 16 & a.compareDocumentPosition(bup)));
|
||||
} : function(a, b) {
|
||||
|
@ -784,7 +784,7 @@
|
||||
}
|
||||
config._a = [], getParsingFlags(config).empty = !0;
|
||||
var locale, hour, meridiem, isPm, i, parsedInput, tokens1, token, skipped, era, string = '' + config._i, stringLength = string.length, totalParsedInputLength = 0;
|
||||
for(i = 0, tokens1 = expandFormat(config._f, config._locale).match(formattingTokens) || []; i < tokens1.length; i++)(token = tokens1[i], (parsedInput = (string.match(hasOwnProp(regexes, token) ? regexes[token](config._strict, config._locale) : RegExp(regexEscape(token.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function(matched, p1, p2, p3, p4) {
|
||||
for(i = 0, tokens1 = expandFormat(config._f, config._locale).match(formattingTokens) || []; i < tokens1.length; i++)(token = tokens1[i], (parsedInput = (string.match(hasOwnProp(regexes, token) ? regexes[token](config._strict, config._locale) : new RegExp(regexEscape(token.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function(matched, p1, p2, p3, p4) {
|
||||
return p1 || p2 || p3 || p4;
|
||||
})))) || [])[0]) && ((skipped = string.substr(0, string.indexOf(parsedInput))).length > 0 && getParsingFlags(config).unusedInput.push(skipped), string = string.slice(string.indexOf(parsedInput) + parsedInput.length), totalParsedInputLength += parsedInput.length), formatTokenFunctions[token]) ? (parsedInput ? getParsingFlags(config).empty = !1 : getParsingFlags(config).unusedTokens.push(token), null != parsedInput && hasOwnProp(tokens, token) && tokens[token](parsedInput, config._a, config, token)) : config._strict && !parsedInput && getParsingFlags(config).unusedTokens.push(token);
|
||||
getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength, string.length > 0 && getParsingFlags(config).unusedInput.push(string), config._a[3] <= 12 && !0 === getParsingFlags(config).bigHour && config._a[3] > 0 && (getParsingFlags(config).bigHour = void 0), getParsingFlags(config).parsedDateParts = config._a.slice(0), getParsingFlags(config).meridiem = config._meridiem, config._a[3] = (locale = config._locale, hour = config._a[3], null == (meridiem = config._meridiem) ? hour : null != locale.meridiemHour ? locale.meridiemHour(hour, meridiem) : (null != locale.isPM && ((isPm = locale.isPM(meridiem)) && hour < 12 && (hour += 12), isPm || 12 !== hour || (hour = 0)), hour)), null !== (era = getParsingFlags(config).era) && (config._a[0] = config._locale.erasConvertYear(era, config._a[0])), configFromArray(config), checkOverflow(config);
|
||||
|
@ -4174,7 +4174,7 @@
|
||||
let comments = options.comments;
|
||||
if ("string" == typeof options.comments && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
|
||||
var regex_pos = options.comments.lastIndexOf("/");
|
||||
comments = RegExp(options.comments.substr(1, regex_pos - 1), options.comments.substr(regex_pos + 1));
|
||||
comments = new RegExp(options.comments.substr(1, regex_pos - 1), options.comments.substr(regex_pos + 1));
|
||||
}
|
||||
comment_filter = comments instanceof RegExp ? function(comment) {
|
||||
return "comment5" != comment.type && comments.test(comment.value);
|
||||
@ -8393,7 +8393,7 @@
|
||||
return params.push(value), arg !== value;
|
||||
})) {
|
||||
let [source, flags] = params;
|
||||
source = regexp_source_fix(RegExp(source).source);
|
||||
source = regexp_source_fix(new RegExp(source).source);
|
||||
const rx = make_node(AST_RegExp, self1, {
|
||||
value: {
|
||||
source,
|
||||
@ -17715,7 +17715,7 @@
|
||||
}(reserved);
|
||||
var cname = -1;
|
||||
cache = options.cache ? options.cache.props : new Map();
|
||||
var regex = options.regex && RegExp(options.regex), debug = !1 !== options.debug;
|
||||
var regex = options.regex && new RegExp(options.regex), debug = !1 !== options.debug;
|
||||
debug && (debug_name_suffix = !0 === options.debug ? "" : options.debug);
|
||||
var names_to_mangle = new Set(), unmangleable = new Set();
|
||||
cache.forEach((mangled_name)=>unmangleable.add(mangled_name));
|
||||
@ -17956,7 +17956,7 @@
|
||||
}), (node)=>{
|
||||
if (node instanceof AST_Assign) {
|
||||
var name = node.left.print_to_string(), value = node.right;
|
||||
return flag ? options[name] = value : value instanceof AST_Array ? options[name] = value.elements.map(to_string) : value instanceof AST_RegExp ? (value = value.value, options[name] = RegExp(value.source, value.flags)) : options[name] = to_string(value), !0;
|
||||
return flag ? options[name] = value : value instanceof AST_Array ? options[name] = value.elements.map(to_string) : value instanceof AST_RegExp ? (value = value.value, options[name] = new RegExp(value.source, value.flags)) : options[name] = to_string(value), !0;
|
||||
}
|
||||
if (node instanceof AST_Symbol || node instanceof AST_PropAccess) {
|
||||
var name = node.print_to_string();
|
||||
@ -18003,7 +18003,7 @@
|
||||
var entries = fs.readdirSync(dir);
|
||||
} catch (ex) {}
|
||||
if (entries) {
|
||||
var rx = RegExp("^" + path.basename(glob).replace(/[.+^$[\]\\(){}]/g, "\\$&").replace(/\*/g, "[^/\\\\]*").replace(/\?/g, "[^/\\\\]") + "$", "win32" === process.platform ? "i" : ""), results = entries.filter(function(name) {
|
||||
var pattern = "^" + path.basename(glob).replace(/[.+^$[\]\\(){}]/g, "\\$&").replace(/\*/g, "[^/\\\\]*").replace(/\?/g, "[^/\\\\]") + "$", mod = "win32" === process.platform ? "i" : "", rx = new RegExp(pattern, mod), results = entries.filter(function(name) {
|
||||
return rx.test(name);
|
||||
}).map(function(name) {
|
||||
return path.join(dir, name);
|
||||
|
@ -7324,7 +7324,7 @@
|
||||
return [
|
||||
function(regexp) {
|
||||
var O = requireObjectCoercible(this), matcher = void 0 == regexp ? void 0 : getMethod(regexp, MATCH);
|
||||
return matcher ? matcher.call(regexp, O) : RegExp(regexp)[MATCH](toString1(O));
|
||||
return matcher ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](toString1(O));
|
||||
},
|
||||
function(string) {
|
||||
var result, rx = anObject(this), S = toString1(string), res = maybeCallNative(nativeMatch, rx, S);
|
||||
@ -7468,7 +7468,7 @@
|
||||
return [
|
||||
function(regexp) {
|
||||
var O = requireObjectCoercible(this), searcher = void 0 == regexp ? void 0 : getMethod(regexp, SEARCH);
|
||||
return searcher ? searcher.call(regexp, O) : RegExp(regexp)[SEARCH](toString1(O));
|
||||
return searcher ? searcher.call(regexp, O) : new RegExp(regexp)[SEARCH](toString1(O));
|
||||
},
|
||||
function(string) {
|
||||
var rx = anObject(this), S = toString1(string), res = maybeCallNative(nativeSearch, rx, S);
|
||||
|
@ -457,7 +457,7 @@
|
||||
}
|
||||
}
|
||||
_t.EMPTY_BYTE_STRING = new _t("");
|
||||
const mt = RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
||||
const mt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
||||
function gt(t) {
|
||||
if (t || L(), "string" == typeof t) {
|
||||
let e = 0;
|
||||
|
@ -784,7 +784,7 @@
|
||||
}
|
||||
config._a = [], getParsingFlags(config).empty = !0;
|
||||
var locale, hour, meridiem, isPm, i, parsedInput, tokens1, token, skipped, era, string = "" + config._i, stringLength = string.length, totalParsedInputLength = 0;
|
||||
for(i = 0, tokens1 = expandFormat(config._f, config._locale).match(formattingTokens) || []; i < tokens1.length; i++)(token = tokens1[i], (parsedInput = (string.match(hasOwnProp(regexes, token) ? regexes[token](config._strict, config._locale) : RegExp(regexEscape(token.replace("\\", "").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function(matched, p1, p2, p3, p4) {
|
||||
for(i = 0, tokens1 = expandFormat(config._f, config._locale).match(formattingTokens) || []; i < tokens1.length; i++)(token = tokens1[i], (parsedInput = (string.match(hasOwnProp(regexes, token) ? regexes[token](config._strict, config._locale) : new RegExp(regexEscape(token.replace("\\", "").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function(matched, p1, p2, p3, p4) {
|
||||
return p1 || p2 || p3 || p4;
|
||||
})))) || [])[0]) && ((skipped = string.substr(0, string.indexOf(parsedInput))).length > 0 && getParsingFlags(config).unusedInput.push(skipped), string = string.slice(string.indexOf(parsedInput) + parsedInput.length), totalParsedInputLength += parsedInput.length), formatTokenFunctions[token]) ? (parsedInput ? getParsingFlags(config).empty = !1 : getParsingFlags(config).unusedTokens.push(token), null != parsedInput && hasOwnProp(tokens, token) && tokens[token](parsedInput, config._a, config, token)) : config._strict && !parsedInput && getParsingFlags(config).unusedTokens.push(token);
|
||||
getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength, string.length > 0 && getParsingFlags(config).unusedInput.push(string), config._a[3] <= 12 && !0 === getParsingFlags(config).bigHour && config._a[3] > 0 && (getParsingFlags(config).bigHour = void 0), getParsingFlags(config).parsedDateParts = config._a.slice(0), getParsingFlags(config).meridiem = config._meridiem, config._a[3] = (locale = config._locale, hour = config._a[3], null == (meridiem = config._meridiem) ? hour : null != locale.meridiemHour ? locale.meridiemHour(hour, meridiem) : (null != locale.isPM && ((isPm = locale.isPM(meridiem)) && hour < 12 && (hour += 12), isPm || 12 !== hour || (hour = 0)), hour)), null !== (era = getParsingFlags(config).era) && (config._a[0] = config._locale.erasConvertYear(era, config._a[0])), configFromArray(config), checkOverflow(config);
|
||||
|
@ -524,7 +524,7 @@
|
||||
yellow: "#ffff00",
|
||||
yellowgreen: "#9acd32"
|
||||
}, CSS_UNIT = "(?:".concat("[-\\+]?\\d*\\.\\d+%?", ")|(?:").concat("[-\\+]?\\d+%?", ")"), PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?"), PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?"), matchers = {
|
||||
CSS_UNIT: RegExp(CSS_UNIT),
|
||||
CSS_UNIT: new RegExp(CSS_UNIT),
|
||||
rgb: RegExp("rgb" + PERMISSIVE_MATCH3),
|
||||
rgba: RegExp("rgba" + PERMISSIVE_MATCH4),
|
||||
hsl: RegExp("hsl" + PERMISSIVE_MATCH3),
|
||||
|
@ -2958,7 +2958,7 @@
|
||||
return inChClass ? inChClass = "]" != square : square ? inChClass = !0 : parenClose ? (stack == lastCapture.stack && (lastCapture.end = index + 1, lastCapture.stack = -1), stack--) : parenOpen && (stack++, 1 != parenOpen.length && (lastCapture.stack = stack, lastCapture.start = index)), m;
|
||||
}), null != lastCapture.end && /^\)*$/.test(src.substr(lastCapture.end)) && (src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end));
|
||||
}
|
||||
return "^" != src.charAt(0) && (src = "^" + src), "$" != src.charAt(src.length - 1) && (src += "$"), RegExp(src, (flag || "").replace("g", ""));
|
||||
return "^" != src.charAt(0) && (src = "^" + src), "$" != src.charAt(src.length - 1) && (src += "$"), new RegExp(src, (flag || "").replace("g", ""));
|
||||
}, this.getLineTokens = function(line, startState) {
|
||||
if (startState && "string" != typeof startState) {
|
||||
var stack = startState.slice(0);
|
||||
@ -5361,7 +5361,7 @@
|
||||
var iterator = new TokenIterator(this, row, column), token = iterator.getCurrentToken(), type = token && token.type;
|
||||
if (token && /^comment|string/.test(type)) {
|
||||
"comment" == (type = type.match(/comment|string/)[0]) && (type += "|doc-start");
|
||||
var re = RegExp(type), range = new Range();
|
||||
var re = new RegExp(type), range = new Range();
|
||||
if (1 != dir) {
|
||||
do token = iterator.stepBackward();
|
||||
while (token && re.test(token.type))
|
||||
@ -6419,14 +6419,14 @@
|
||||
var modifier = options.caseSensitive ? "gm" : "gmi";
|
||||
if (options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle), options.$isMultiLine) return options.re = this.$assembleMultilineRegExp(needle, modifier);
|
||||
try {
|
||||
var re = RegExp(needle, modifier);
|
||||
var re = new RegExp(needle, modifier);
|
||||
} catch (e) {
|
||||
re = !1;
|
||||
}
|
||||
return options.re = re;
|
||||
}, this.$assembleMultilineRegExp = function(needle, modifier) {
|
||||
for(var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n"), re = [], i = 0; i < parts.length; i++)try {
|
||||
re.push(RegExp(parts[i], modifier));
|
||||
re.push(new RegExp(parts[i], modifier));
|
||||
} catch (e) {
|
||||
return !1;
|
||||
}
|
||||
|
@ -2071,13 +2071,13 @@
|
||||
], tb = [
|
||||
function(e) {
|
||||
return e.map(function(e) {
|
||||
var t, r = RegExp((t = e.attributes.font, tv.reduce(function(e, r) {
|
||||
var t, r = (t = e.attributes.font, tv.reduce(function(e, r) {
|
||||
return t && t.hasGlyphForCodePoint && t.hasGlyphForCodePoint(r) ? e : [].concat(e, [
|
||||
String.fromCharCode(r)
|
||||
]);
|
||||
}, [])).join("|"));
|
||||
}, [])), n = new RegExp(r.join("|"));
|
||||
return {
|
||||
string: e.string.replace(r, ""),
|
||||
string: e.string.replace(n, ""),
|
||||
attributes: e.attributes
|
||||
};
|
||||
});
|
||||
@ -7343,7 +7343,7 @@
|
||||
if (null === o) return null;
|
||||
if (0 == c || "object" != typeof o) return o;
|
||||
if (e.__isArray(o)) f = [];
|
||||
else if (e.__isRegExp(o)) f = RegExp(o.source, r(o)), o.lastIndex && (f.lastIndex = o.lastIndex);
|
||||
else if (e.__isRegExp(o)) f = new RegExp(o.source, r(o)), o.lastIndex && (f.lastIndex = o.lastIndex);
|
||||
else if (e.__isDate(o)) f = new Date(o.getTime());
|
||||
else {
|
||||
if (s && n.isBuffer(o)) return f = n.allocUnsafe ? n.allocUnsafe(o.length) : new n(o.length), o.copy(f), f;
|
||||
|
@ -5483,7 +5483,7 @@
|
||||
], Touch.prototype, "swipeSettings", void 0), Touch = touch_decorate([
|
||||
NotifyPropertyChanges
|
||||
], Touch);
|
||||
}(Base), LINES = RegExp('\\n|\\r|\\s\\s+', 'g'), QUOTES = RegExp(/'|"/g), IF_STMT = RegExp('if ?\\('), ELSEIF_STMT = RegExp('else if ?\\('), ELSE_STMT = /else/, FOR_STMT = RegExp('for ?\\('), IF_OR_FOR = RegExp('(/if|/for)'), CALL_FUNCTION = RegExp('\\((.*)\\)', ''), NOT_NUMBER = RegExp('^[0-9]+$', 'g'), WORD = RegExp('[\\w"\'.\\s+]+', 'g'), DBL_QUOTED_STR = RegExp('"(.*?)"', 'g'), WORDIF = RegExp('[\\w"\'@#$.\\s-+]+', 'g'), exp = RegExp('\\${([^}]*)}', 'g'), ARR_OBJ = /^\..*/gm, SINGLE_SLASH = /\\/gi, DOUBLE_SLASH = /\\\\/gi, WORDFUNC = RegExp('[\\w"\'@#$.\\s+]+', 'g'), WINDOWFUNC = /\window\./gm;
|
||||
}(Base), LINES = RegExp('\\n|\\r|\\s\\s+', 'g'), QUOTES = new RegExp(/'|"/g), IF_STMT = RegExp('if ?\\('), ELSEIF_STMT = RegExp('else if ?\\('), ELSE_STMT = /else/, FOR_STMT = RegExp('for ?\\('), IF_OR_FOR = RegExp('(/if|/for)'), CALL_FUNCTION = RegExp('\\((.*)\\)', ''), NOT_NUMBER = RegExp('^[0-9]+$', 'g'), WORD = RegExp('[\\w"\'.\\s+]+', 'g'), DBL_QUOTED_STR = RegExp('"(.*?)"', 'g'), WORDIF = RegExp('[\\w"\'@#$.\\s-+]+', 'g'), exp = RegExp('\\${([^}]*)}', 'g'), ARR_OBJ = /^\..*/gm, SINGLE_SLASH = /\\/gi, DOUBLE_SLASH = /\\\\/gi, WORDFUNC = RegExp('[\\w"\'@#$.\\s+]+', 'g'), WINDOWFUNC = /\window\./gm;
|
||||
function addNameSpace(str, addNS, nameSpace, ignoreList, ignorePrefix) {
|
||||
return !addNS || NOT_NUMBER.test(str) || -1 !== ignoreList.indexOf(str.split('.')[0]) || ignorePrefix ? str : nameSpace + '.' + str;
|
||||
}
|
||||
@ -11174,7 +11174,7 @@
|
||||
return styleEle.rel = 'stylesheet', styleEle;
|
||||
}, RichTextEditor.prototype.setValue = function() {
|
||||
if (this.valueTemplate) {
|
||||
if (RegExp(/<(?=.*? .*?\/ ?>|br|hr|input|!--|wbr)[a-z]+.*?>|<([a-z]+).*?<\/\1>/i).test(this.valueTemplate)) this.setProperties({
|
||||
if (new RegExp(/<(?=.*? .*?\/ ?>|br|hr|input|!--|wbr)[a-z]+.*?>|<([a-z]+).*?<\/\1>/i).test(this.valueTemplate)) this.setProperties({
|
||||
value: this.valueTemplate
|
||||
});
|
||||
else {
|
||||
@ -14562,7 +14562,7 @@
|
||||
this.checkVShape(elm);
|
||||
for(var imgElem = elm.querySelectorAll('img'), i = 0; i < imgElem.length; i++)!(0, ej2_base.le)(imgElem[i].getAttribute('v:shapes')) && 0 > imgElem[i].getAttribute('v:shapes').indexOf('Picture') && 0 > imgElem[i].getAttribute('v:shapes').indexOf('Image') && (0, ej2_base.og)(imgElem[i]);
|
||||
imgElem = elm.querySelectorAll('img');
|
||||
var imgSrc = [], base64Src = [], imgName = [], linkRegex = RegExp(/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi);
|
||||
var imgSrc = [], base64Src = [], imgName = [], linkRegex = new RegExp(/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi);
|
||||
if (imgElem.length > 0) {
|
||||
for(var i = 0; i < imgElem.length; i++)imgSrc.push(imgElem[i].getAttribute('src')), imgName.push(imgElem[i].getAttribute('src').split('/')[imgElem[i].getAttribute('src').split('/').length - 1].split('.')[0]);
|
||||
for(var hexValue = this.hexConversion(rtfData), i = 0; i < hexValue.length; i++)base64Src.push(this.convertToBase64(hexValue[i]));
|
||||
@ -15623,13 +15623,13 @@
|
||||
for(var node = rangeLiNode.parentElement; node !== this.parent.inputElement && (1 !== node.nodeType || 'LI' !== node.tagName);)node = node.parentElement;
|
||||
return node;
|
||||
}, HtmlEditor.prototype.onPaste = function(e) {
|
||||
var regex = RegExp(/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi);
|
||||
var regex = new RegExp(/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi);
|
||||
if (e.text.match(regex)) {
|
||||
if (e.isWordPaste) return;
|
||||
e.args.preventDefault();
|
||||
var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
||||
this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
|
||||
for(var httpRegex = RegExp(/([^\S]|^)(((https?\:\/\/)))/gi), wwwRegex = RegExp(/([^\S]|^)(((www\.))(\S+))/gi), enterSplitText = e.text.split('\n'), contentInnerElem = '', i = 0; i < enterSplitText.length; i++)if ('' === enterSplitText[i].trim()) contentInnerElem += (0, util.oG)(this.parent);
|
||||
for(var httpRegex = new RegExp(/([^\S]|^)(((https?\:\/\/)))/gi), wwwRegex = new RegExp(/([^\S]|^)(((www\.))(\S+))/gi), enterSplitText = e.text.split('\n'), contentInnerElem = '', i = 0; i < enterSplitText.length; i++)if ('' === enterSplitText[i].trim()) contentInnerElem += (0, util.oG)(this.parent);
|
||||
else {
|
||||
for(var contentWithSpace = '', spaceBetweenContent = !0, spaceSplit = enterSplitText[i].split(' '), j = 0; j < spaceSplit.length; j++)'' === spaceSplit[j].trim() ? contentWithSpace += spaceBetweenContent ? ' ' : ' ' : (spaceBetweenContent = !1, contentWithSpace += spaceSplit[j] + ' ');
|
||||
0 === i ? contentInnerElem += '<span>' + contentWithSpace.trim() + '</span>' : contentInnerElem += '<p>' + contentWithSpace.trim() + '</p>';
|
||||
@ -15645,7 +15645,7 @@
|
||||
}, HtmlEditor.prototype.spaceLink = function(e) {
|
||||
var range = this.nodeSelectionObj.getRange(this.contentRenderer.getDocument()), selectNodeEle = this.nodeSelectionObj.getParentNodeCollection(range), text = range.startContainer.textContent.substr(0, range.endOffset), splitText = text.split(' '), urlText = splitText[splitText.length - 1], urlTextRange = range.startOffset - (text.length - splitText[splitText.length - 1].length);
|
||||
urlText = urlText.slice(0, urlTextRange);
|
||||
var regex = RegExp(/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi);
|
||||
var regex = new RegExp(/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi);
|
||||
if ('A' !== selectNodeEle[0].nodeName && urlText.match(regex)) {
|
||||
var selection = this.nodeSelectionObj.save(range, this.parent.contentModule.getDocument()), value = {
|
||||
url: urlText.indexOf('http') > -1 ? urlText : 'http://' + urlText,
|
||||
@ -18058,7 +18058,7 @@
|
||||
value: value
|
||||
}), e.args && null !== value && 'HTML' === this.parent.editorMode) {
|
||||
if (0 === value.length) {
|
||||
var htmlRegex = RegExp(/<\/[a-z][\s\S]*>/i);
|
||||
var htmlRegex = new RegExp(/<\/[a-z][\s\S]*>/i);
|
||||
value = e.args.clipboardData.getData('text/plain'), this.isNotFromHtml = '' !== value, value = (value = value.replace(/</g, '<')).replace(/>/g, '>'), this.containsHtml = htmlRegex.test(value);
|
||||
var file = e && e.args.clipboardData && e.args.clipboardData.items.length > 0 ? null === e.args.clipboardData.items[0].getAsFile() ? (0, ej2_base.le)(e.args.clipboardData.items[1]) ? null : e.args.clipboardData.items[1].getAsFile() : e.args.clipboardData.items[0].getAsFile() : null;
|
||||
if (this.parent.notify(constant.RE, {
|
||||
@ -19641,7 +19641,7 @@
|
||||
item.id ? ele.id = item.id : ele.id = (0, ej2_base.QI)('tbr-ipt'), innerEle.appendChild(ele), templateProp.appendTo(ele);
|
||||
}
|
||||
} else {
|
||||
var templateFn = void 0, val = templateProp, regEx = RegExp(/<(?=.*? .*?\/ ?>|br|hr|input|!--|wbr)[a-z]+.*?>|<([a-z]+).*?<\/\1>/i);
|
||||
var templateFn = void 0, val = templateProp, regEx = new RegExp(/<(?=.*? .*?\/ ?>|br|hr|input|!--|wbr)[a-z]+.*?>|<([a-z]+).*?<\/\1>/i);
|
||||
val = 'string' == typeof templateProp ? templateProp.trim() : templateProp;
|
||||
try {
|
||||
if ('object' != typeof templateProp || (0, ej2_base.le)(templateProp.tagName)) {
|
||||
|
@ -1545,7 +1545,7 @@
|
||||
const matchers = yield Promise.resolve(options.router.pageLoader.getMiddleware());
|
||||
if (!matchers) return !1;
|
||||
const { pathname: asPathname } = _parsePath.parsePath(options.asPath), cleanedAs = _hasBasePath.hasBasePath(asPathname) ? _removeBasePath.removeBasePath(asPathname) : asPathname, asWithBasePathAndLocale = _addBasePath.addBasePath(_addLocale.addLocale(cleanedAs, options.locale));
|
||||
return matchers.some((m)=>RegExp(m.regexp).test(asWithBasePathAndLocale));
|
||||
return matchers.some((m)=>new RegExp(m.regexp).test(asWithBasePathAndLocale));
|
||||
})).apply(this, arguments);
|
||||
}
|
||||
function stripOrigin(url) {
|
||||
@ -2682,7 +2682,7 @@
|
||||
function getRouteRegex(normalizedRoute) {
|
||||
const { parameterizedRoute , groups } = getParametrizedRoute(normalizedRoute);
|
||||
return {
|
||||
re: RegExp("^".concat(parameterizedRoute, "(?:/)?$")),
|
||||
re: new RegExp("^".concat(parameterizedRoute, "(?:/)?$")),
|
||||
groups: groups
|
||||
};
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -148,7 +148,7 @@
|
||||
}), source)destination[key] = copy(source[key]);
|
||||
setHashKey(destination, h);
|
||||
}
|
||||
} else destination = source, source && (isArray(source) ? destination = copy(source, []) : isDate(source) ? destination = new Date(source.getTime()) : isRegExp(source) ? destination = RegExp(source.source) : isObject(source) && (destination = copy(source, {})));
|
||||
} else destination = source, source && (isArray(source) ? destination = copy(source, []) : isDate(source) ? destination = new Date(source.getTime()) : isRegExp(source) ? destination = new RegExp(source.source) : isObject(source) && (destination = copy(source, {})));
|
||||
return destination;
|
||||
}
|
||||
function equals(o1, o2) {
|
||||
@ -3605,7 +3605,7 @@
|
||||
if (ctrl.$isEmpty(value) || regexp.test(value)) return ctrl.$setValidity("pattern", !0), value;
|
||||
ctrl.$setValidity("pattern", !1);
|
||||
};
|
||||
if (pattern && ((match = pattern.match(/^\/(.*)\/([gim]*)$/)) ? (pattern = RegExp(match[1], match[2]), patternValidator = function(value) {
|
||||
if (pattern && ((match = pattern.match(/^\/(.*)\/([gim]*)$/)) ? (pattern = new RegExp(match[1], match[2]), patternValidator = function(value) {
|
||||
return validate(pattern, value);
|
||||
}) : patternValidator = function(value) {
|
||||
var patternObj = scope.$eval(pattern);
|
||||
@ -3722,7 +3722,7 @@
|
||||
return {
|
||||
require: "ngModel",
|
||||
link: function(scope, element, attr, ctrl) {
|
||||
var match = /\/(.*)\//.exec(attr.ngList), separator = match && RegExp(match[1]) || attr.ngList || ",";
|
||||
var match = /\/(.*)\//.exec(attr.ngList), separator = match && new RegExp(match[1]) || attr.ngList || ",";
|
||||
ctrl.$parsers.push(function(viewValue) {
|
||||
if (!isUndefined(viewValue)) {
|
||||
var list = [];
|
||||
|
@ -1114,7 +1114,7 @@
|
||||
var i, cachedruns, Expr, getText, isXML, compile, hasDuplicate, outermostContext, setDocument, document, docElem, documentIsXML, rbuggyQSA, rbuggyMatches, matches, contains, sortOrder, expando = "sizzle" + -new Date(), preferredDoc = window1.document, support = {}, dirruns = 0, done = 0, classCache = createCache(), tokenCache = createCache(), compilerCache = createCache(), strundefined = "undefined", arr = [], pop = arr.pop, push = arr.push, slice = arr.slice, indexOf = arr.indexOf || function(elem) {
|
||||
for(var i = 0, len = this.length; i < len; i++)if (this[i] === elem) return i;
|
||||
return -1;
|
||||
}, whitespace = "[\\x20\\t\\r\\n\\f]", characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", identifier = characterEncoding.replace("w", "w#"), attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace(3, 8) + ")*)|.*)\\)|)", rtrim = RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"), rcomma = RegExp("^" + whitespace + "*," + whitespace + "*"), rcombinators = RegExp("^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*"), rpseudo = RegExp(pseudos), ridentifier = RegExp("^" + identifier + "$"), matchExpr = {
|
||||
}, whitespace = "[\\x20\\t\\r\\n\\f]", characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", identifier = characterEncoding.replace("w", "w#"), attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace(3, 8) + ")*)|.*)\\)|)", rtrim = RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"), rcomma = RegExp("^" + whitespace + "*," + whitespace + "*"), rcombinators = RegExp("^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*"), rpseudo = new RegExp(pseudos), ridentifier = RegExp("^" + identifier + "$"), matchExpr = {
|
||||
ID: RegExp("^#(" + characterEncoding + ")"),
|
||||
CLASS: RegExp("^\\.(" + characterEncoding + ")"),
|
||||
NAME: RegExp("^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]"),
|
||||
@ -1285,7 +1285,7 @@
|
||||
div.innerHTML = "<input type='hidden' i=''/>", div.querySelectorAll("[i^='']").length && rbuggyQSA.push("[*^$]=" + whitespace + "*(?:\"\"|'')"), div.querySelectorAll(":enabled").length || rbuggyQSA.push(":enabled", ":disabled"), div.querySelectorAll("*,:x"), rbuggyQSA.push(",.*:");
|
||||
})), (support.matchesSelector = isNative(matches = docElem.matchesSelector || docElem.mozMatchesSelector || docElem.webkitMatchesSelector || docElem.oMatchesSelector || docElem.msMatchesSelector)) && assert(function(div) {
|
||||
support.disconnectedMatch = matches.call(div, "div"), matches.call(div, "[s!='']:x"), rbuggyMatches.push("!=", pseudos);
|
||||
}), rbuggyQSA = RegExp(rbuggyQSA.join("|")), rbuggyMatches = RegExp(rbuggyMatches.join("|")), contains = isNative(docElem.contains) || docElem.compareDocumentPosition ? function(a, b) {
|
||||
}), rbuggyQSA = new RegExp(rbuggyQSA.join("|")), rbuggyMatches = new RegExp(rbuggyMatches.join("|")), contains = isNative(docElem.contains) || docElem.compareDocumentPosition ? function(a, b) {
|
||||
var adown = 9 === a.nodeType ? a.documentElement : a, bup = b && b.parentNode;
|
||||
return a === bup || !!(bup && 1 === bup.nodeType && (adown.contains ? adown.contains(bup) : a.compareDocumentPosition && 16 & a.compareDocumentPosition(bup)));
|
||||
} : function(a, b) {
|
||||
|
@ -1108,7 +1108,7 @@ Event.Keys = {}, Event.Keys = new Hash(Event.Keys), function() {
|
||||
return string.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, function(match) {
|
||||
return "\\" + match;
|
||||
});
|
||||
}, regexp = RegExp("^(?:\\s*(,)\\s*|\\s*(<combinator>+)\\s*|(\\s+)|(<unicode>+|\\*)|\\#(<unicode>+)|\\.(<unicode>+)|\\[\\s*(<unicode1>+)(?:\\s*([*^$!~|]?=)(?:\\s*(?:([\"']?)(.*?)\\9)))?\\s*\\](?!\\])|(:+)(<unicode>+)(?:\\((?:(?:([\"'])([^\\13]*)\\13)|((?:\\([^)]+\\)|[^()]*)+))\\))?)".replace(/<combinator>/, "[" + escapeRegExp(">+~`!@$%^&={}\\;</") + "]").replace(/<unicode>/g, "(?:[\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])").replace(/<unicode1>/g, "(?:[:\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])"));
|
||||
}, regexp = new RegExp("^(?:\\s*(,)\\s*|\\s*(<combinator>+)\\s*|(\\s+)|(<unicode>+|\\*)|\\#(<unicode>+)|\\.(<unicode>+)|\\[\\s*(<unicode1>+)(?:\\s*([*^$!~|]?=)(?:\\s*(?:([\"']?)(.*?)\\9)))?\\s*\\](?!\\])|(:+)(<unicode>+)(?:\\((?:(?:([\"'])([^\\13]*)\\13)|((?:\\([^)]+\\)|[^()]*)+))\\))?)".replace(/<combinator>/, "[" + escapeRegExp(">+~`!@$%^&={}\\;</") + "]").replace(/<unicode>/g, "(?:[\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])").replace(/<unicode1>/g, "(?:[:\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])"));
|
||||
function parser(rawMatch, separator, combinator, combinatorChildren, tagName, id, className1, attributeKey, attributeOperator, attributeQuote, attributeValue, pseudoMarker, pseudoClass, pseudoQuote, pseudoClassQuotedValue, pseudoClassValue) {
|
||||
if ((separator || -1 === separatorIndex) && (parsed.expressions[++separatorIndex] = [], combinatorIndex = -1, separator)) return "";
|
||||
if (combinator || combinatorChildren || -1 === combinatorIndex) {
|
||||
|
Loading…
Reference in New Issue
Block a user