mirror of
https://github.com/swc-project/swc.git
synced 2024-10-04 12:18:08 +03:00
fix(es/minifier): Abort seq inliner if a same var is defined in outer scope (#7772)
**Description:** The algorithm here is directly copied from terser, I don't if it's correct or can be improved, but it does fix the issue. **Related issue:** - Closes #7749
This commit is contained in:
parent
c04ca528b8
commit
ef8d12154d
@ -613,6 +613,12 @@ impl Take for AssignExpr {
|
||||
}
|
||||
}
|
||||
|
||||
impl AssignExpr {
|
||||
pub fn is_simple_assign(&self) -> bool {
|
||||
self.op == op!("=") && self.left.as_ident().is_some()
|
||||
}
|
||||
}
|
||||
|
||||
// Custom deserializer to convert `PatOrExpr::Pat(Box<Pat::Ident>)`
|
||||
// to `PatOrExpr::Expr(Box<Expr::Ident>)` when `op` is not `=`.
|
||||
// Same logic as parser:
|
||||
|
@ -869,9 +869,21 @@ impl Optimizer<'_> {
|
||||
let ids: Vec<Id> = find_pat_ids(&decl.name);
|
||||
|
||||
for id in ids {
|
||||
remap
|
||||
.entry(id)
|
||||
let ctx = remap
|
||||
.entry(id.clone())
|
||||
.or_insert_with(|| SyntaxContext::empty().apply_mark(Mark::new()));
|
||||
|
||||
// [is_skippable_for_seq] would check fn scope
|
||||
if let Some(usage) = self.data.vars.get(&id) {
|
||||
let mut usage = usage.clone();
|
||||
usage.in_fn_scope_of = self.ctx.fn_scope;
|
||||
// as we turn var declaration into assignment
|
||||
// we need to maintain correct var usage
|
||||
if decl.init.is_some() {
|
||||
usage.ref_count += 1;
|
||||
}
|
||||
self.data.vars.insert((id.0, *ctx), usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +174,9 @@ struct Ctx {
|
||||
|
||||
/// Current scope.
|
||||
scope: SyntaxContext,
|
||||
|
||||
/// Current function scope
|
||||
fn_scope: SyntaxContext,
|
||||
}
|
||||
|
||||
impl Ctx {
|
||||
@ -2134,6 +2137,7 @@ impl VisitMut for Optimizer<'_> {
|
||||
skip_standalone: self.ctx.skip_standalone || is_standalone,
|
||||
in_fn_like: true,
|
||||
scope: n.span.ctxt,
|
||||
fn_scope: n.span.ctxt,
|
||||
top_level: false,
|
||||
|
||||
..self.ctx
|
||||
|
@ -1158,25 +1158,14 @@ impl Optimizer<'_> {
|
||||
)
|
||||
}),
|
||||
Mergable::Expr(a) => match a {
|
||||
Expr::Assign(AssignExpr {
|
||||
left,
|
||||
right,
|
||||
op: op!("="),
|
||||
..
|
||||
}) => {
|
||||
if left.as_ident().is_some() {
|
||||
Some(collect_infects_from(
|
||||
right,
|
||||
AliasConfig {
|
||||
marks: Some(self.marks),
|
||||
ignore_nested: true,
|
||||
need_all: true,
|
||||
},
|
||||
))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
Expr::Assign(a) if a.is_simple_assign() => Some(collect_infects_from(
|
||||
&a.right,
|
||||
AliasConfig {
|
||||
marks: Some(self.marks),
|
||||
ignore_nested: true,
|
||||
need_all: true,
|
||||
},
|
||||
)),
|
||||
|
||||
_ => None,
|
||||
},
|
||||
@ -1270,18 +1259,43 @@ impl Optimizer<'_> {
|
||||
};
|
||||
|
||||
if let Some(a) = a {
|
||||
let left_fn_scope = self
|
||||
.data
|
||||
.vars
|
||||
.get(&left_id.to_id())
|
||||
.map(|u| u.in_fn_scope_of)
|
||||
.unwrap_or(self.expr_ctx.unresolved_ctxt);
|
||||
match a {
|
||||
Mergable::Var(a) => {
|
||||
if is_ident_used_by(left_id.to_id(), &**a) {
|
||||
log_abort!("e.left is used by a (var)");
|
||||
return false;
|
||||
}
|
||||
|
||||
if let Some(init) = &a.init {
|
||||
if init.may_have_side_effects(&self.expr_ctx)
|
||||
&& self.ctx.fn_scope != left_fn_scope
|
||||
{
|
||||
log_abort!("a (var) init has side effect");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Mergable::Expr(a) => {
|
||||
if is_ident_used_by(left_id.to_id(), &**a) {
|
||||
log_abort!("e.left is used by a (expr)");
|
||||
return false;
|
||||
}
|
||||
let has_side_effect = match a {
|
||||
Expr::Assign(a) if a.is_simple_assign() => {
|
||||
a.right.may_have_side_effects(&self.expr_ctx)
|
||||
}
|
||||
_ => a.may_have_side_effects(&self.expr_ctx),
|
||||
};
|
||||
if has_side_effect && self.ctx.fn_scope != left_fn_scope {
|
||||
log_abort!("a (expr) has side effect");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Mergable::FnDecl(a) => {
|
||||
// TODO(kdy1): I'm not sure if this check is required.
|
||||
@ -1725,9 +1739,10 @@ impl Optimizer<'_> {
|
||||
}
|
||||
|
||||
let b_left = b_assign.left.as_ident();
|
||||
let b_left = match b_left {
|
||||
Some(v) => v.clone(),
|
||||
None => return Ok(false),
|
||||
let b_left = if let Some(v) = b_left {
|
||||
v.clone()
|
||||
} else {
|
||||
return Ok(false);
|
||||
};
|
||||
|
||||
if !self.is_skippable_for_seq(Some(a), &Expr::Ident(b_left.clone())) {
|
||||
@ -2213,7 +2228,11 @@ impl Optimizer<'_> {
|
||||
}
|
||||
|
||||
// We can remove this variable same as unused pass
|
||||
if !usage.reassigned() && usage.usage_count == 1 && usage.declared {
|
||||
if !usage.reassigned()
|
||||
&& usage.usage_count == 1
|
||||
&& usage.declared
|
||||
&& !usage.used_recursively
|
||||
{
|
||||
can_remove = true;
|
||||
}
|
||||
} else {
|
||||
|
@ -137,6 +137,8 @@ pub(crate) struct VarUsageInfo {
|
||||
pub(crate) accessed_props: Box<AHashMap<JsWord, u32>>,
|
||||
|
||||
pub(crate) used_recursively: bool,
|
||||
|
||||
pub(crate) in_fn_scope_of: SyntaxContext,
|
||||
}
|
||||
|
||||
impl Default for VarUsageInfo {
|
||||
@ -177,6 +179,7 @@ impl Default for VarUsageInfo {
|
||||
is_top_level: Default::default(),
|
||||
assigned_fn_local: true,
|
||||
used_as_ref: false,
|
||||
in_fn_scope_of: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -364,6 +367,7 @@ impl Storage for ProgramData {
|
||||
// }
|
||||
|
||||
let v = self.vars.entry(i.to_id()).or_default();
|
||||
v.in_fn_scope_of = ctx.fn_scope;
|
||||
v.is_top_level |= ctx.is_top_level;
|
||||
|
||||
if has_init && (v.declared || v.var_initialized) {
|
||||
|
@ -26730,21 +26730,21 @@
|
||||
}
|
||||
function updateRectShape(controller, cover, name, x, y, w, h) {
|
||||
var points, xmin, ymin, el = cover.childOfName(name);
|
||||
el && el.setShape((xmin = mathMin$9((points = clipByPanel(controller, cover, [
|
||||
[
|
||||
x,
|
||||
y
|
||||
],
|
||||
[
|
||||
x + w,
|
||||
y + h
|
||||
]
|
||||
]))[0][0], points[1][0]), {
|
||||
x: xmin,
|
||||
el && el.setShape({
|
||||
x: xmin = mathMin$9((points = clipByPanel(controller, cover, [
|
||||
[
|
||||
x,
|
||||
y
|
||||
],
|
||||
[
|
||||
x + w,
|
||||
y + h
|
||||
]
|
||||
]))[0][0], points[1][0]),
|
||||
y: ymin = mathMin$9(points[0][1], points[1][1]),
|
||||
width: mathMax$9(points[0][0], points[1][0]) - xmin,
|
||||
height: mathMax$9(points[0][1], points[1][1]) - ymin
|
||||
}));
|
||||
});
|
||||
}
|
||||
function makeStyle(brushOption) {
|
||||
return defaults({
|
||||
@ -34700,25 +34700,25 @@
|
||||
header.innerHTML = lang[0] || model.get('title'), header.style.cssText = 'margin: 10px 20px;', header.style.color = model.get('textColor');
|
||||
var viewMain = document.createElement('div'), textarea = document.createElement('textarea');
|
||||
viewMain.style.cssText = 'display:block;width:100%;overflow:auto;';
|
||||
var optionToContent = model.get('optionToContent'), contentToOption = model.get('contentToOption'), result1 = (seriesGroupByCategoryAxis = {}, otherSeries = [], meta = [], ecModel.eachRawSeries(function(seriesModel) {
|
||||
var coordSys = seriesModel.coordinateSystem;
|
||||
if (coordSys && ('cartesian2d' === coordSys.type || 'polar' === coordSys.type)) {
|
||||
var baseAxis = coordSys.getBaseAxis();
|
||||
if ('category' === baseAxis.type) {
|
||||
var key = baseAxis.dim + '_' + baseAxis.index;
|
||||
seriesGroupByCategoryAxis[key] || (seriesGroupByCategoryAxis[key] = {
|
||||
categoryAxis: baseAxis,
|
||||
valueAxis: coordSys.getOtherAxis(baseAxis),
|
||||
series: []
|
||||
}, meta.push({
|
||||
axisDim: baseAxis.dim,
|
||||
axisIndex: baseAxis.index
|
||||
})), seriesGroupByCategoryAxis[key].series.push(seriesModel);
|
||||
} else otherSeries.push(seriesModel);
|
||||
} else otherSeries.push(seriesModel);
|
||||
}), {
|
||||
var optionToContent = model.get('optionToContent'), contentToOption = model.get('contentToOption'), result1 = {
|
||||
value: filter([
|
||||
(groups = (result = {
|
||||
(groups = (seriesGroupByCategoryAxis = {}, otherSeries = [], meta = [], ecModel.eachRawSeries(function(seriesModel) {
|
||||
var coordSys = seriesModel.coordinateSystem;
|
||||
if (coordSys && ('cartesian2d' === coordSys.type || 'polar' === coordSys.type)) {
|
||||
var baseAxis = coordSys.getBaseAxis();
|
||||
if ('category' === baseAxis.type) {
|
||||
var key = baseAxis.dim + '_' + baseAxis.index;
|
||||
seriesGroupByCategoryAxis[key] || (seriesGroupByCategoryAxis[key] = {
|
||||
categoryAxis: baseAxis,
|
||||
valueAxis: coordSys.getOtherAxis(baseAxis),
|
||||
series: []
|
||||
}, meta.push({
|
||||
axisDim: baseAxis.dim,
|
||||
axisIndex: baseAxis.index
|
||||
})), seriesGroupByCategoryAxis[key].series.push(seriesModel);
|
||||
} else otherSeries.push(seriesModel);
|
||||
} else otherSeries.push(seriesModel);
|
||||
}), result = {
|
||||
seriesGroupByCategoryAxis: seriesGroupByCategoryAxis,
|
||||
other: otherSeries,
|
||||
meta: meta
|
||||
@ -34757,7 +34757,7 @@
|
||||
return !!str.replace(/[\n\t\s]/g, '');
|
||||
}).join('\n\n' + BLOCK_SPLITER + '\n\n'),
|
||||
meta: result.meta
|
||||
});
|
||||
};
|
||||
if ('function' == typeof optionToContent) {
|
||||
var htmlOrDom = optionToContent(api.getOption());
|
||||
'string' == typeof htmlOrDom ? viewMain.innerHTML = htmlOrDom : isDom(htmlOrDom) && viewMain.appendChild(htmlOrDom);
|
||||
|
@ -13437,9 +13437,9 @@
|
||||
return childComponents.map(function(child, index) {
|
||||
var child1, props1, calculatedProps1, domain, scale, stringMap, categories, axisChild, role = child.type && child.type.role, style = Array.isArray(child.props.style) ? child.props.style : lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default()({}, child.props.style, {
|
||||
parent: baseStyle
|
||||
}), childProps = (child1 = child, props1 = props, calculatedProps1 = calculatedProps, axisChild = victory_core__WEBPACK_IMPORTED_MODULE_3__.Axis.findAxisComponents([
|
||||
}), childProps = (child1 = child, props1 = props, calculatedProps1 = calculatedProps, (axisChild = victory_core__WEBPACK_IMPORTED_MODULE_3__.Axis.findAxisComponents([
|
||||
child1
|
||||
]), axisChild.length > 0 ? (axisChild[0], domain = calculatedProps1.domain, scale = calculatedProps1.scale, stringMap = calculatedProps1.stringMap, categories = calculatedProps1.categories, {
|
||||
])).length > 0 ? (axisChild[0], domain = calculatedProps1.domain, scale = calculatedProps1.scale, stringMap = calculatedProps1.stringMap, categories = calculatedProps1.categories, {
|
||||
stringMap: stringMap,
|
||||
horizontal: calculatedProps1.horizontal,
|
||||
categories: categories,
|
||||
@ -18467,8 +18467,8 @@
|
||||
x: x,
|
||||
y: y
|
||||
};
|
||||
var polarPadding = (style = props.style, degrees = getDegrees(props, datum), labelStyle = style.labels || {}, padding = _helpers__WEBPACK_IMPORTED_MODULE_1__.default.evaluateProp(labelStyle.padding, props) || 0, {
|
||||
x: padding * Math.cos(angle = _helpers__WEBPACK_IMPORTED_MODULE_1__.default.degreesToRadians(degrees)),
|
||||
var polarPadding = (style = props.style, degrees = getDegrees(props, datum), labelStyle = style.labels || {}, {
|
||||
x: (padding = _helpers__WEBPACK_IMPORTED_MODULE_1__.default.evaluateProp(labelStyle.padding, props) || 0) * Math.cos(angle = _helpers__WEBPACK_IMPORTED_MODULE_1__.default.degreesToRadians(degrees)),
|
||||
y: -padding * Math.sin(angle)
|
||||
});
|
||||
return {
|
||||
@ -28248,9 +28248,9 @@
|
||||
{
|
||||
key: "getCachedSharedEvents",
|
||||
value: function(name, cacheValues) {
|
||||
var arr, _ref2 = function(arr) {
|
||||
var _ref = this.sharedEventsCache[name] || [], _ref2 = function(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}(arr = this.sharedEventsCache[name] || []) || function(arr, i) {
|
||||
}(_ref) || function(arr, i) {
|
||||
var _arr = [], _n = !0, _d = !1, _e = void 0;
|
||||
try {
|
||||
for(var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0);
|
||||
@ -28264,7 +28264,7 @@
|
||||
}
|
||||
}
|
||||
return _arr;
|
||||
}(arr, 2) || function() {
|
||||
}(_ref, 2) || function() {
|
||||
throw TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}(), sharedEvents = _ref2[0], prevCacheValues = _ref2[1];
|
||||
if (sharedEvents && react_fast_compare__WEBPACK_IMPORTED_MODULE_10___default()(cacheValues, prevCacheValues)) return sharedEvents;
|
||||
@ -28468,13 +28468,13 @@
|
||||
return dataset.filter(function(datum) {
|
||||
return null !== datum._x && null !== datum._y;
|
||||
});
|
||||
}), fillInMissingData = props1.fillInMissingData, xMap = filterNullChildData.reduce(function(prev, dataset) {
|
||||
}), (fillInMissingData = props1.fillInMissingData, xMap = filterNullChildData.reduce(function(prev, dataset) {
|
||||
return dataset.forEach(function(datum) {
|
||||
prev[datum._x instanceof Date ? datum._x.getTime() : datum._x] = !0;
|
||||
}), prev;
|
||||
}, {}), xKeys = lodash_keys__WEBPACK_IMPORTED_MODULE_1___default()(xMap).map(function(k) {
|
||||
return +k;
|
||||
}), xArr = lodash_orderBy__WEBPACK_IMPORTED_MODULE_0___default()(xKeys), (datasets = filterNullChildData.map(function(dataset) {
|
||||
}), xArr = lodash_orderBy__WEBPACK_IMPORTED_MODULE_0___default()(xKeys), datasets = filterNullChildData.map(function(dataset) {
|
||||
var indexOffset = 0, isDate = dataset[0] && dataset[0]._x instanceof Date;
|
||||
return xArr.map(function(x, index) {
|
||||
x = +x;
|
||||
|
@ -1532,7 +1532,7 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
Vue = Vue1, configDef = {}, configDef.get = function() {
|
||||
Vue = Vue1, (configDef = {}).get = function() {
|
||||
return config;
|
||||
}, configDef.set = function() {
|
||||
warn('Do not replace the Vue.config object, set individual fields instead.');
|
||||
@ -2921,7 +2921,7 @@
|
||||
warn$1 = _warn;
|
||||
var code, number, valueBinding, trueValueBinding, falseValueBinding, number1, valueBinding1, value = dir.value, modifiers = dir.modifiers, tag = el.tag, type = el.attrsMap.type;
|
||||
if ('input' === tag && 'file' === type && warn$1("<" + el.tag + " v-model=\"" + value + '" type="file">:\nFile inputs are read only. Use a v-on:change listener instead.', el.rawAttrsMap['v-model']), el.component) return genComponentModel(el, value, modifiers), !1;
|
||||
if ('select' === tag) addHandler(el, 'change', code = (code = 'var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return ' + (modifiers && modifiers.number ? '_n(val)' : 'val') + "});") + " " + genAssignmentCode(value, '$event.target.multiple ? $$selectedVal : $$selectedVal[0]'), null, !0);
|
||||
if ('select' === tag) addHandler(el, 'change', 'var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return ' + (modifiers && modifiers.number ? '_n(val)' : 'val') + "}); " + genAssignmentCode(value, '$event.target.multiple ? $$selectedVal : $$selectedVal[0]'), null, !0);
|
||||
else if ('input' === tag && 'checkbox' === type) number = modifiers && modifiers.number, valueBinding = getBindingAttr(el, 'value') || 'null', trueValueBinding = getBindingAttr(el, 'true-value') || 'true', falseValueBinding = getBindingAttr(el, 'false-value') || 'false', addProp(el, 'checked', "Array.isArray(" + value + ")?_i(" + value + "," + valueBinding + ")>-1" + ('true' === trueValueBinding ? ":(" + value + ")" : ":_q(" + value + "," + trueValueBinding + ")")), addHandler(el, 'change', "var $$a=" + value + ",$$el=$event.target,$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");if(Array.isArray($$a)){var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + ",$$i=_i($$a,$$v);if($$el.checked){$$i<0&&(" + genAssignmentCode(value, '$$a.concat([$$v])') + ")}else{$$i>-1&&(" + genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))') + ")}}else{" + genAssignmentCode(value, '$$c') + "}", null, !0);
|
||||
else if ('input' === tag && 'radio' === type) number1 = modifiers && modifiers.number, valueBinding1 = getBindingAttr(el, 'value') || 'null', valueBinding1 = number1 ? "_n(" + valueBinding1 + ")" : valueBinding1, addProp(el, 'checked', "_q(" + value + "," + valueBinding1 + ")"), addHandler(el, 'change', genAssignmentCode(value, valueBinding1), null, !0);
|
||||
else if ('input' === tag || 'textarea' === tag) !function(el, value, modifiers) {
|
||||
@ -3091,7 +3091,7 @@
|
||||
if (el.for && !el.forProcessed) return genFor(el, state);
|
||||
if (el.if && !el.ifProcessed) return genIf(el, state);
|
||||
if ('template' === el.tag && !el.slotTarget && !state.pre) return genChildren(el, state) || 'void 0';
|
||||
if ('slot' === el.tag) return slotName = el.slotName || '"default"', res = "_t(" + slotName + ((children = genChildren(el, state)) ? "," + children : ''), attrs = el.attrs || el.dynamicAttrs ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function(attr) {
|
||||
if ('slot' === el.tag) return res = "_t(" + (el.slotName || '"default"') + ((children = genChildren(el, state)) ? "," + children : ''), attrs = el.attrs || el.dynamicAttrs ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function(attr) {
|
||||
return {
|
||||
name: camelize(attr.name),
|
||||
value: attr.value,
|
||||
@ -3101,7 +3101,7 @@
|
||||
if (el.component) componentName = el.component, children1 = el.inlineTemplate ? null : genChildren(el, state, !0), code = "_c(" + componentName + "," + genData$2(el, state) + (children1 ? "," + children1 : '') + ")";
|
||||
else {
|
||||
(!el.plain || el.pre && state.maybeComponent(el)) && (data = genData$2(el, state));
|
||||
var slotName, children, res, attrs, bind$$1, code, componentName, children1, data, children2 = el.inlineTemplate ? null : genChildren(el, state, !0);
|
||||
var children, res, attrs, bind$$1, code, componentName, children1, data, children2 = el.inlineTemplate ? null : genChildren(el, state, !0);
|
||||
code = "_c('" + el.tag + "'" + (data ? "," + data : '') + (children2 ? "," + children2 : '') + ")";
|
||||
}
|
||||
for(var i = 0; i < state.transforms.length; i++)code = state.transforms[i](el, code);
|
||||
|
@ -1,4 +1,4 @@
|
||||
var ClassB, value;
|
||||
var ClassB, obj, value;
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) throw TypeError("Cannot call a class as a function");
|
||||
}
|
||||
@ -8,7 +8,7 @@ function _defineProperties(target, props) {
|
||||
descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
module.exports = (ClassB = function() {
|
||||
module.exports = (obj = ClassB = function() {
|
||||
"use strict";
|
||||
var protoProps, staticProps;
|
||||
function ClassB() {
|
||||
@ -25,9 +25,9 @@ module.exports = (ClassB = function() {
|
||||
}(), value = function ClassA() {
|
||||
"use strict";
|
||||
_classCallCheck(this, ClassA);
|
||||
}, "MyA" in ClassB ? Object.defineProperty(ClassB, "MyA", {
|
||||
}, "MyA" in obj ? Object.defineProperty(obj, "MyA", {
|
||||
value: value,
|
||||
enumerable: !0,
|
||||
configurable: !0,
|
||||
writable: !0
|
||||
}) : ClassB.MyA = value, ClassB);
|
||||
}) : obj.MyA = value, ClassB);
|
||||
|
10
crates/swc_ecma_minifier/tests/fixture/issues/7749/input.js
Normal file
10
crates/swc_ecma_minifier/tests/fixture/issues/7749/input.js
Normal file
@ -0,0 +1,10 @@
|
||||
let depth = 0;
|
||||
|
||||
function foo(n) {
|
||||
depth += 1;
|
||||
let k = visit(n);
|
||||
depth -= 1;
|
||||
return k;
|
||||
}
|
||||
|
||||
blackbox(foo);
|
@ -0,0 +1,6 @@
|
||||
let depth = 0;
|
||||
blackbox(function(n) {
|
||||
depth += 1;
|
||||
let k = visit(n);
|
||||
return depth -= 1, k;
|
||||
});
|
@ -1990,6 +1990,11 @@
|
||||
c ? (a = ag(a, b, Wf), d.__reactInternalMemoizedMergedChildContext = a, E(Vf), E(H), G(H, a)) : E(Vf), G(Vf, c);
|
||||
}
|
||||
var dg = null, eg = !1, fg = !1;
|
||||
function gg(a) {
|
||||
null === dg ? dg = [
|
||||
a
|
||||
] : dg.push(a);
|
||||
}
|
||||
function ig() {
|
||||
if (!fg && null !== dg) {
|
||||
fg = !0;
|
||||
@ -4071,7 +4076,7 @@
|
||||
return (null !== P || null !== vg) && 0 != (1 & a.mode) && 0 == (2 & W);
|
||||
}
|
||||
function Ck(a, b) {
|
||||
var a1, a2, b1, c = a.callbackNode;
|
||||
var a1, b1, a2, c = a.callbackNode;
|
||||
!function(a, b) {
|
||||
for(var c = a.suspendedLanes, d = a.pingedLanes, e = a.expirationTimes, f = a.pendingLanes; 0 < f;){
|
||||
var g = 31 - nc(f), h = 1 << g, k = e[g];
|
||||
@ -4110,9 +4115,7 @@
|
||||
var d = tc(a, a === P ? Y : 0);
|
||||
if (0 === d) null !== c && ac(c), a.callbackNode = null, a.callbackPriority = 0;
|
||||
else if (b = d & -d, a.callbackPriority !== b) {
|
||||
if (null != c && ac(c), 1 === b) 0 === a.tag && (eg = !0), a1 = Dk.bind(null, a), null === dg ? dg = [
|
||||
a1
|
||||
] : dg.push(a1), If(function() {
|
||||
if (null != c && ac(c), 1 === b) 0 === a.tag ? (a2 = Dk.bind(null, a), eg = !0, gg(a2)) : gg(Dk.bind(null, a)), If(function() {
|
||||
0 === W && ig();
|
||||
}), c = null;
|
||||
else {
|
||||
@ -4130,7 +4133,7 @@
|
||||
case 536870912:
|
||||
c = ic;
|
||||
}
|
||||
a2 = c, b1 = Fk.bind(null, a), c = $b(a2, b1);
|
||||
a1 = c, b1 = Fk.bind(null, a), c = $b(a1, b1);
|
||||
}
|
||||
a.callbackPriority = b, a.callbackNode = c;
|
||||
}
|
||||
|
@ -5524,33 +5524,33 @@
|
||||
compile: new (function() {
|
||||
function Engine() {}
|
||||
return Engine.prototype.compile = function(templateString, helper, ignorePrefix) {
|
||||
var helper1, argName, str, helper2, ignorePrefix1, varCOunt, localKeys, isClass, singleSpace;
|
||||
return void 0 === helper && (helper = {}), argName = 'data', str = templateString, helper2 = helper1 = helper, ignorePrefix1 = void 0, varCOunt = 0, localKeys = [], isClass = str.match(/class="([^"]+|)\s{2}/g), singleSpace = '', isClass && isClass.forEach(function(value) {
|
||||
var helper1, argName, str, nameSpace, helper2, ignorePrefix1, varCOunt, localKeys, isClass, singleSpace;
|
||||
return void 0 === helper && (helper = {}), str = templateString, nameSpace = argName = 'data', helper2 = helper1 = helper, ignorePrefix1 = void 0, varCOunt = 0, localKeys = [], isClass = str.match(/class="([^"]+|)\s{2}/g), singleSpace = '', isClass && isClass.forEach(function(value) {
|
||||
singleSpace = value.replace(/\s\s+/g, ' '), str = str.replace(value, singleSpace);
|
||||
}), Function(argName, "var str=\"" + str.replace(LINES, '').replace(DBL_QUOTED_STR, '\'$1\'').replace(exp, function(match, cnt, offset, matchStr) {
|
||||
var matches = cnt.match(CALL_FUNCTION);
|
||||
if (matches) {
|
||||
var rlStr = matches[1];
|
||||
if (ELSEIF_STMT.test(cnt)) cnt = '";} ' + cnt.replace(matches[1], rlStr.replace(WORD, function(str) {
|
||||
return addNameSpace(str = str.trim(), !QUOTES.test(str) && -1 === localKeys.indexOf(str), argName, localKeys, ignorePrefix1);
|
||||
return addNameSpace(str = str.trim(), !QUOTES.test(str) && -1 === localKeys.indexOf(str), nameSpace, localKeys, ignorePrefix1);
|
||||
})) + '{ \n str = str + "';
|
||||
else if (IF_STMT.test(cnt)) cnt = '"; ' + cnt.replace(matches[1], rlStr.replace(WORDIF, function(strs) {
|
||||
return HandleSpecialCharArrObj(strs, argName, localKeys, ignorePrefix1);
|
||||
return HandleSpecialCharArrObj(strs, nameSpace, localKeys, ignorePrefix1);
|
||||
})) + '{ \n str = str + "';
|
||||
else if (FOR_STMT.test(cnt)) {
|
||||
var rlStr_1 = matches[1].split(' of ');
|
||||
cnt = '"; ' + cnt.replace(matches[1], function(mtc) {
|
||||
return localKeys.push(rlStr_1[0]), localKeys.push(rlStr_1[0] + 'Index'), 'var i' + (varCOunt += 1) + '=0; i' + varCOunt + ' < ' + addNameSpace(rlStr_1[1], !0, argName, localKeys, ignorePrefix1) + '.length; i' + varCOunt + '++';
|
||||
}) + '{ \n ' + rlStr_1[0] + '= ' + addNameSpace(rlStr_1[1], !0, argName, localKeys, ignorePrefix1) + '[i' + varCOunt + ']; \n var ' + rlStr_1[0] + 'Index=i' + varCOunt + '; \n str = str + "';
|
||||
return localKeys.push(rlStr_1[0]), localKeys.push(rlStr_1[0] + 'Index'), 'var i' + (varCOunt += 1) + '=0; i' + varCOunt + ' < ' + addNameSpace(rlStr_1[1], !0, nameSpace, localKeys, ignorePrefix1) + '.length; i' + varCOunt + '++';
|
||||
}) + '{ \n ' + rlStr_1[0] + '= ' + addNameSpace(rlStr_1[1], !0, nameSpace, localKeys, ignorePrefix1) + '[i' + varCOunt + ']; \n var ' + rlStr_1[0] + 'Index=i' + varCOunt + '; \n str = str + "';
|
||||
} else {
|
||||
var fnStr = cnt.split('('), fNameSpace = helper2 && helper2.hasOwnProperty(fnStr[0]) ? 'this.' : 'global';
|
||||
fNameSpace = /\./.test(fnStr[0]) ? '' : fNameSpace;
|
||||
var ftArray = matches[1].split(',');
|
||||
0 === matches[1].length || /data/.test(ftArray[0]) || /window./.test(ftArray[0]) || (matches[1] = 'global' === fNameSpace ? argName + '.' + matches[1] : matches[1]), WINDOWFUNC.test(cnt) && /\]\./gm.test(cnt) || /@|\$|#/gm.test(cnt) ? /@|\$|#|\]\./gm.test(cnt) && (cnt = '"+ ' + ('global' === fNameSpace ? '' : fNameSpace) + cnt.replace(matches[1], rlStr.replace(WORDFUNC, function(strs) {
|
||||
return HandleSpecialCharArrObj(strs, argName, localKeys, ignorePrefix1);
|
||||
})) + '+ "') : cnt = '" + ' + ('global' === fNameSpace ? '' : fNameSpace) + cnt.replace(rlStr, addNameSpace(matches[1].replace(/,( |)data.|,/gi, ',' + argName + '.').replace(/,( |)data.window/gi, ',window'), 'global' !== fNameSpace, argName, localKeys, ignorePrefix1)) + '+"';
|
||||
0 === matches[1].length || /data/.test(ftArray[0]) || /window./.test(ftArray[0]) || (matches[1] = 'global' === fNameSpace ? nameSpace + '.' + matches[1] : matches[1]), WINDOWFUNC.test(cnt) && /\]\./gm.test(cnt) || /@|\$|#/gm.test(cnt) ? /@|\$|#|\]\./gm.test(cnt) && (cnt = '"+ ' + ('global' === fNameSpace ? '' : fNameSpace) + cnt.replace(matches[1], rlStr.replace(WORDFUNC, function(strs) {
|
||||
return HandleSpecialCharArrObj(strs, nameSpace, localKeys, ignorePrefix1);
|
||||
})) + '+ "') : cnt = '" + ' + ('global' === fNameSpace ? '' : fNameSpace) + cnt.replace(rlStr, addNameSpace(matches[1].replace(/,( |)data.|,/gi, ',' + nameSpace + '.').replace(/,( |)data.window/gi, ',window'), 'global' !== fNameSpace, nameSpace, localKeys, ignorePrefix1)) + '+"';
|
||||
}
|
||||
} else ELSE_STMT.test(cnt) ? cnt = '"; ' + cnt.replace(ELSE_STMT, '} else { \n str = str + "') : cnt.match(IF_OR_FOR) ? cnt = cnt.replace(IF_OR_FOR, '"; \n } \n str = str + "') : /@|#|\$/gm.test(cnt) ? (cnt.match(SINGLE_SLASH) && (cnt = SlashReplace(cnt)), cnt = '"+' + NameSpaceForspecialChar(cnt, -1 === localKeys.indexOf(cnt), argName, localKeys) + '"]+"') : cnt = cnt.match(SINGLE_SLASH) ? '"+' + NameSpaceForspecialChar(cnt = SlashReplace(cnt), -1 === localKeys.indexOf(cnt), argName, localKeys) + '"]+"' : '"+' + addNameSpace(cnt.replace(/,/gi, '+' + argName + '.'), -1 === localKeys.indexOf(cnt), argName, localKeys, ignorePrefix1) + '+"';
|
||||
} else ELSE_STMT.test(cnt) ? cnt = '"; ' + cnt.replace(ELSE_STMT, '} else { \n str = str + "') : cnt.match(IF_OR_FOR) ? cnt = cnt.replace(IF_OR_FOR, '"; \n } \n str = str + "') : /@|#|\$/gm.test(cnt) ? (cnt.match(SINGLE_SLASH) && (cnt = SlashReplace(cnt)), cnt = '"+' + NameSpaceForspecialChar(cnt, -1 === localKeys.indexOf(cnt), nameSpace, localKeys) + '"]+"') : cnt = cnt.match(SINGLE_SLASH) ? '"+' + NameSpaceForspecialChar(cnt = SlashReplace(cnt), -1 === localKeys.indexOf(cnt), nameSpace, localKeys) + '"]+"' : '"+' + addNameSpace(cnt.replace(/,/gi, '+' + nameSpace + '.'), -1 === localKeys.indexOf(cnt), nameSpace, localKeys, ignorePrefix1) + '+"';
|
||||
return cnt;
|
||||
}) + "\";var valueRegEx = (/value=\\'([A-Za-z0-9 _]*)((.)([\\w)(!-;?-■\\s]+)['])/g);\n var hrefRegex = (/(?:href)([\\s='\"./]+)([\\w-./?=&\\\\#\"]+)((.)([\\w)(!-;/?-■\\s]+)['])/g);\n if(str.match(valueRegEx)){\n var check = str.match(valueRegEx);\n var str1 = str;\n for (var i=0; i < check.length; i++) {\n var check1 = str.match(valueRegEx)[i].split('value=')[1];\n var change = check1.match(/^'/) !== null ? check1.replace(/^'/, '\"') : check1;\n change =change.match(/.$/)[0] === '\\'' ? change.replace(/.$/,'\"') : change;\n str1 = str1.replace(check1, change);\n }\n str = str.replace(str, str1);\n }\n else if (str.match(/(?:href='')/) === null) {\n if(str.match(hrefRegex)) {\n var check = str.match(hrefRegex);\n var str1 = str;\n for (var i=0; i < check.length; i++) {\n var check1 = str.match(hrefRegex)[i].split('href=')[1];\n if (check1) {\n var change = check1.match(/^'/) !== null ? check1.replace(/^'/, '\"') : check1;\n change =change.match(/.$/)[0] === '\\'' ? change.replace(/.$/,'\"') : change;\n str1 = str1.replace(check1, change);\n }\n }\n str = str.replace(str, str1);\n }\n }\n return str;").bind(helper1);
|
||||
}, Engine;
|
||||
|
File diff suppressed because one or more lines are too long
@ -1312,7 +1312,7 @@
|
||||
if (isString(className = node.className) && "" !== className) for(; match = CLASS_DIRECTIVE_REGEXP.exec(className);)addDirective(directives, nName = directiveNormalize(match[2]), "C", maxPriority, ignoreDirective) && (attrs[nName] = trim(match[3])), className = className.substr(match.index + match[0].length);
|
||||
break;
|
||||
case 3:
|
||||
directives1 = directives, interpolateFn = $interpolate(node.nodeValue, !0), interpolateFn && directives1.push({
|
||||
directives1 = directives, (interpolateFn = $interpolate(node.nodeValue, !0)) && directives1.push({
|
||||
priority: 0,
|
||||
compile: valueFn(function(scope, node) {
|
||||
var parent = node.parent(), bindings = parent.data("$binding") || [];
|
||||
@ -3342,7 +3342,7 @@
|
||||
var descending = !1, get = predicate || identity;
|
||||
return isString(predicate) && (("+" == predicate.charAt(0) || "-" == predicate.charAt(0)) && (descending = "-" == predicate.charAt(0), predicate = predicate.substring(1)), get = $parse(predicate)), reverseComparator(function(a, b) {
|
||||
var v1, v2, t1, t2;
|
||||
return v1 = get(a), v2 = get(b), t1 = typeof v1, t2 = typeof v2, t1 != t2 ? t1 < t2 ? -1 : 1 : ("string" == t1 && (v1 = v1.toLowerCase(), v2 = v2.toLowerCase()), v1 === v2) ? 0 : v1 < v2 ? -1 : 1;
|
||||
return v1 = get(a), v2 = get(b), (t1 = typeof v1) != (t2 = typeof v2) ? t1 < t2 ? -1 : 1 : ("string" == t1 && (v1 = v1.toLowerCase(), v2 = v2.toLowerCase()), v1 === v2) ? 0 : v1 < v2 ? -1 : 1;
|
||||
}, descending);
|
||||
}, results = [], forEach(obj, function(value, index, list) {
|
||||
results.push(iterator.call(void 0, value, index, list));
|
||||
|
@ -3341,7 +3341,7 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
handleEventFunc && handleEventFunc(domEventName, targetNode, targetInst), "focusout" !== domEventName || (state = (node = targetNode)._wrapperState, !state || !state.controlled || "number" !== node.type || setDefaultValue(node, "number", node.value));
|
||||
handleEventFunc && handleEventFunc(domEventName, targetNode, targetInst), "focusout" !== domEventName || !(state = (node = targetNode)._wrapperState) || !state.controlled || "number" !== node.type || setDefaultValue(node, "number", node.value);
|
||||
}(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget), function(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
|
||||
var targetNode = targetInst ? getNodeFromInstance(targetInst) : window;
|
||||
switch(domEventName){
|
||||
@ -4947,7 +4947,7 @@
|
||||
case 5:
|
||||
returnFiber.type, parentProps = returnFiber.memoizedProps, parentInstance = returnFiber.stateNode, !0 !== parentProps[SUPPRESS_HYDRATION_WARNING$1] && (1 === instance.nodeType ? warnForDeletedHydratableElement(parentInstance, instance) : 8 === instance.nodeType || warnForDeletedHydratableText(parentInstance, instance));
|
||||
}
|
||||
var fiber, parentContainer, parentType, parentProps, parentInstance, childToDelete = (fiber = createFiber(5, null, null, 0), fiber.elementType = "DELETED", fiber.type = "DELETED", fiber);
|
||||
var fiber, parentContainer, parentType, parentProps, parentInstance, childToDelete = ((fiber = createFiber(5, null, null, 0)).elementType = "DELETED", fiber.type = "DELETED", fiber);
|
||||
childToDelete.stateNode = instance, childToDelete.return = returnFiber, childToDelete.flags = 8, null !== returnFiber.lastEffect ? (returnFiber.lastEffect.nextEffect = childToDelete, returnFiber.lastEffect = childToDelete) : returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
|
||||
}
|
||||
function insertNonHydratedInstance(returnFiber, fiber) {
|
||||
@ -6290,16 +6290,16 @@
|
||||
else showFallback = !0, workInProgress.flags &= -65;
|
||||
if (push(suspenseStackCursor, suspenseContext &= 1, workInProgress), null === current) {
|
||||
void 0 !== nextProps.fallback && tryToClaimNextHydratableInstance(workInProgress);
|
||||
var suspenseContext1, current1, workInProgress1, renderLanes1, workInProgress2, primaryChildren, renderLanes2, mode, primaryChildFragment, nextPrimaryChildren = nextProps.children, nextFallbackChildren = nextProps.fallback;
|
||||
var suspenseContext1, current1, workInProgress1, renderLanes1, workInProgress2, primaryChildren, renderLanes2, primaryChildFragment, nextPrimaryChildren = nextProps.children, nextFallbackChildren = nextProps.fallback;
|
||||
if (showFallback) {
|
||||
var fallbackFragment = mountSuspenseFallbackChildren(workInProgress, nextPrimaryChildren, nextFallbackChildren, renderLanes);
|
||||
return workInProgress.child.memoizedState = mountSuspenseOffscreenState(renderLanes), workInProgress.memoizedState = SUSPENDED_MARKER, fallbackFragment;
|
||||
}
|
||||
if ("number" != typeof nextProps.unstable_expectedLoadTime) {
|
||||
return workInProgress2 = workInProgress, primaryChildren = nextPrimaryChildren, renderLanes2 = renderLanes, mode = workInProgress2.mode, primaryChildFragment = createFiberFromOffscreen({
|
||||
return workInProgress2 = workInProgress, primaryChildren = nextPrimaryChildren, renderLanes2 = renderLanes, (primaryChildFragment = createFiberFromOffscreen({
|
||||
mode: "visible",
|
||||
children: primaryChildren
|
||||
}, mode, renderLanes2, null), primaryChildFragment.return = workInProgress2, workInProgress2.child = primaryChildFragment, primaryChildFragment;
|
||||
}, workInProgress2.mode, renderLanes2, null)).return = workInProgress2, workInProgress2.child = primaryChildFragment, primaryChildFragment;
|
||||
}
|
||||
var _fallbackFragment = mountSuspenseFallbackChildren(workInProgress, nextPrimaryChildren, nextFallbackChildren, renderLanes);
|
||||
return workInProgress.child.memoizedState = mountSuspenseOffscreenState(renderLanes), workInProgress.memoizedState = SUSPENDED_MARKER, workInProgress.lanes = 33554432, markSpawnedWork(33554432), _fallbackFragment;
|
||||
@ -6692,7 +6692,7 @@
|
||||
return reconcileChildren(current, workInProgress, newProps.children, renderLanes), workInProgress.child;
|
||||
}(current, workInProgress, renderLanes);
|
||||
case 9:
|
||||
return current1 = current, workInProgress1 = workInProgress, renderLanes1 = renderLanes, context = workInProgress1.type, void 0 === context._context ? context === context.Consumer || hasWarnedAboutUsingContextAsConsumer || (hasWarnedAboutUsingContextAsConsumer = !0, error("Rendering <Context> directly is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?")) : context = context._context, newProps = workInProgress1.pendingProps, render = newProps.children, "function" != typeof render && error("A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it."), prepareToReadContext(workInProgress1, renderLanes1), newValue1 = readContext(context, newProps.unstable_observedBits), ReactCurrentOwner$1.current = workInProgress1, isRendering = !0, newChildren = render(newValue1), isRendering = !1, workInProgress1.flags |= 1, reconcileChildren(current1, workInProgress1, newChildren, renderLanes1), workInProgress1.child;
|
||||
return current1 = current, workInProgress1 = workInProgress, renderLanes1 = renderLanes, void 0 === (context = workInProgress1.type)._context ? context === context.Consumer || hasWarnedAboutUsingContextAsConsumer || (hasWarnedAboutUsingContextAsConsumer = !0, error("Rendering <Context> directly is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?")) : context = context._context, "function" != typeof (render = (newProps = workInProgress1.pendingProps).children) && error("A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it."), prepareToReadContext(workInProgress1, renderLanes1), newValue1 = readContext(context, newProps.unstable_observedBits), ReactCurrentOwner$1.current = workInProgress1, isRendering = !0, newChildren = render(newValue1), isRendering = !1, workInProgress1.flags |= 1, reconcileChildren(current1, workInProgress1, newChildren, renderLanes1), workInProgress1.child;
|
||||
case 14:
|
||||
var _type2 = workInProgress.type, _resolvedProps3 = resolveDefaultProps(_type2, workInProgress.pendingProps);
|
||||
if (workInProgress.type !== workInProgress.elementType) {
|
||||
@ -7014,7 +7014,7 @@
|
||||
return shouldUpdate;
|
||||
})(workInProgress) && markUpdate(workInProgress);
|
||||
else {
|
||||
workInProgress.stateNode = (validateDOMNesting(null, newProps, _currentHostContext.ancestorInfo), textNode = getOwnerDocumentFromRootContainer(_rootContainerInstance).createTextNode(newProps), hostInst2 = workInProgress, (node4 = textNode)[internalInstanceKey] = hostInst2, textNode);
|
||||
workInProgress.stateNode = (validateDOMNesting(null, newProps, _currentHostContext.ancestorInfo), hostInst2 = workInProgress, (node4 = textNode = getOwnerDocumentFromRootContainer(_rootContainerInstance).createTextNode(newProps))[internalInstanceKey] = hostInst2, textNode);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -7383,7 +7383,7 @@
|
||||
isContainer ? function insertOrAppendPlacementNodeIntoContainer(node, before, parent) {
|
||||
var tag = node.tag, isHost = 5 === tag || 6 === tag;
|
||||
if (isHost) {
|
||||
var parentNode, stateNode = isHost ? node.stateNode : node.stateNode.instance;
|
||||
var parentNode, reactRootContainer, stateNode = isHost ? node.stateNode : node.stateNode.instance;
|
||||
before ? 8 === parent.nodeType ? parent.parentNode.insertBefore(stateNode, before) : parent.insertBefore(stateNode, before) : (8 === parent.nodeType ? (parentNode = parent.parentNode).insertBefore(stateNode, parent) : (parentNode = parent).appendChild(stateNode), null == parent._reactRootContainer && null === parentNode.onclick && trapClickOnNonInteractiveElement(parentNode));
|
||||
} else if (4 === tag) ;
|
||||
else {
|
||||
@ -8107,7 +8107,7 @@
|
||||
else if (outerNode.compareDocumentPosition) return !!(16 & outerNode.compareDocumentPosition(innerNode));
|
||||
else return !1;
|
||||
}(node.ownerDocument.documentElement, node)) {
|
||||
null !== priorSelectionRange && hasSelectionCapabilities(priorFocusedElem) && (input = priorFocusedElem, start = (offsets = priorSelectionRange).start, end = offsets.end, void 0 === end && (end = start), "selectionStart" in input ? (input.selectionStart = start, input.selectionEnd = Math.min(end, input.value.length)) : function(node, offsets) {
|
||||
null !== priorSelectionRange && hasSelectionCapabilities(priorFocusedElem) && (input = priorFocusedElem, start = (offsets = priorSelectionRange).start, void 0 === (end = offsets.end) && (end = start), "selectionStart" in input ? (input.selectionStart = start, input.selectionEnd = Math.min(end, input.value.length)) : function(node, offsets) {
|
||||
var doc = node.ownerDocument || document, win = doc && doc.defaultView || window;
|
||||
if (win.getSelection) {
|
||||
var selection = win.getSelection(), length = node.textContent.length, start = Math.min(offsets.start, length), end = void 0 === offsets.end ? start : Math.min(offsets.end, length);
|
||||
@ -8461,7 +8461,7 @@
|
||||
}
|
||||
function resolveRetryWakeable(boundaryFiber, wakeable) {
|
||||
var retryCache, retryLane, eventTime, root, lane, mode;
|
||||
null !== (retryCache = boundaryFiber.stateNode) && retryCache.delete(wakeable), 0 == (retryLane = 0) && (mode = boundaryFiber.mode, retryLane = (2 & mode) == 0 ? 1 : (4 & mode) == 0 ? 99 === getCurrentPriorityLevel() ? 1 : 2 : (0 === currentEventWipLanes && (currentEventWipLanes = workInProgressRootIncludedLanes), 0 === (lane = pickArbitraryLane(62914560 & ~currentEventWipLanes)) && (lane = pickArbitraryLane(62914560)), lane)), eventTime = requestEventTime(), null !== (root = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane)) && (markRootUpdated(root, retryLane, eventTime), ensureRootIsScheduled(root, eventTime), schedulePendingInteractions(root, retryLane));
|
||||
null !== (retryCache = boundaryFiber.stateNode) && retryCache.delete(wakeable), 0 == (retryLane = 0) && (retryLane = (2 & (mode = boundaryFiber.mode)) == 0 ? 1 : (4 & mode) == 0 ? 99 === getCurrentPriorityLevel() ? 1 : 2 : (0 === currentEventWipLanes && (currentEventWipLanes = workInProgressRootIncludedLanes), 0 === (lane = pickArbitraryLane(62914560 & ~currentEventWipLanes)) && (lane = pickArbitraryLane(62914560)), lane)), eventTime = requestEventTime(), null !== (root = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane)) && (markRootUpdated(root, retryLane, eventTime), ensureRootIsScheduled(root, eventTime), schedulePendingInteractions(root, retryLane));
|
||||
}
|
||||
var didWarnStateUpdateForNotYetMountedComponent = null;
|
||||
function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) {
|
||||
@ -8705,18 +8705,18 @@
|
||||
fiberTag = 8, mode |= 1;
|
||||
break;
|
||||
case REACT_PROFILER_TYPE:
|
||||
return pendingProps1 = pendingProps, mode1 = mode, lanes1 = lanes, key1 = key, "string" != typeof pendingProps1.id && error('Profiler must specify an "id" as a prop'), fiber = createFiber(12, pendingProps1, key1, 8 | mode1), fiber.elementType = REACT_PROFILER_TYPE, fiber.type = REACT_PROFILER_TYPE, fiber.lanes = lanes1, fiber.stateNode = {
|
||||
return pendingProps1 = pendingProps, mode1 = mode, lanes1 = lanes, key1 = key, "string" != typeof pendingProps1.id && error('Profiler must specify an "id" as a prop'), (fiber = createFiber(12, pendingProps1, key1, 8 | mode1)).elementType = REACT_PROFILER_TYPE, fiber.type = REACT_PROFILER_TYPE, fiber.lanes = lanes1, fiber.stateNode = {
|
||||
effectDuration: 0,
|
||||
passiveEffectDuration: 0
|
||||
}, fiber;
|
||||
case REACT_SUSPENSE_TYPE:
|
||||
return pendingProps2 = pendingProps, mode2 = mode, lanes2 = lanes, fiber1 = createFiber(13, pendingProps2, key, mode2), fiber1.type = REACT_SUSPENSE_TYPE, fiber1.elementType = REACT_SUSPENSE_TYPE, fiber1.lanes = lanes2, fiber1;
|
||||
return pendingProps2 = pendingProps, mode2 = mode, lanes2 = lanes, (fiber1 = createFiber(13, pendingProps2, key, mode2)).type = REACT_SUSPENSE_TYPE, fiber1.elementType = REACT_SUSPENSE_TYPE, fiber1.lanes = lanes2, fiber1;
|
||||
case REACT_SUSPENSE_LIST_TYPE:
|
||||
return pendingProps3 = pendingProps, mode3 = mode, lanes3 = lanes, fiber2 = createFiber(19, pendingProps3, key, mode3), fiber2.type = REACT_SUSPENSE_LIST_TYPE, fiber2.elementType = REACT_SUSPENSE_LIST_TYPE, fiber2.lanes = lanes3, fiber2;
|
||||
return pendingProps3 = pendingProps, mode3 = mode, lanes3 = lanes, (fiber2 = createFiber(19, pendingProps3, key, mode3)).type = REACT_SUSPENSE_LIST_TYPE, fiber2.elementType = REACT_SUSPENSE_LIST_TYPE, fiber2.lanes = lanes3, fiber2;
|
||||
case REACT_OFFSCREEN_TYPE:
|
||||
return createFiberFromOffscreen(pendingProps, mode, lanes, key);
|
||||
case REACT_LEGACY_HIDDEN_TYPE:
|
||||
return pendingProps4 = pendingProps, mode4 = mode, lanes4 = lanes, fiber3 = createFiber(24, pendingProps4, key, mode4), fiber3.type = REACT_LEGACY_HIDDEN_TYPE, fiber3.elementType = REACT_LEGACY_HIDDEN_TYPE, fiber3.lanes = lanes4, fiber3;
|
||||
return pendingProps4 = pendingProps, mode4 = mode, lanes4 = lanes, (fiber3 = createFiber(24, pendingProps4, key, mode4)).type = REACT_LEGACY_HIDDEN_TYPE, fiber3.elementType = REACT_LEGACY_HIDDEN_TYPE, fiber3.lanes = lanes4, fiber3;
|
||||
default:
|
||||
if ("object" == typeof type && null !== type) switch(type.$$typeof){
|
||||
case REACT_PROVIDER_TYPE:
|
||||
|
@ -141,6 +141,8 @@ pub struct Ctx {
|
||||
pub is_op_assign: bool,
|
||||
|
||||
pub is_top_level: bool,
|
||||
|
||||
pub fn_scope: SyntaxContext,
|
||||
}
|
||||
|
||||
pub(super) struct WithCtx<'a, S>
|
||||
|
@ -828,6 +828,7 @@ where
|
||||
let ctx = Ctx {
|
||||
skip_standalone: self.ctx.skip_standalone || is_standalone,
|
||||
in_update_arg: false,
|
||||
fn_scope: n.span.ctxt,
|
||||
..self.ctx
|
||||
};
|
||||
|
||||
|
@ -1344,19 +1344,17 @@ pub trait ExprExt {
|
||||
Expr::Fn(..) | Expr::Arrow(..) => false,
|
||||
|
||||
Expr::Class(c) => class_has_side_effect(ctx, &c.class),
|
||||
Expr::Array(ArrayLit { ref elems, .. }) => elems
|
||||
Expr::Array(ArrayLit { elems, .. }) => elems
|
||||
.iter()
|
||||
.filter_map(|e| e.as_ref())
|
||||
.any(|e| e.spread.is_some() || e.expr.may_have_side_effects(ctx)),
|
||||
Expr::Unary(UnaryExpr {
|
||||
op: op!("delete"), ..
|
||||
}) => true,
|
||||
Expr::Unary(UnaryExpr { ref arg, .. }) => arg.may_have_side_effects(ctx),
|
||||
Expr::Bin(BinExpr {
|
||||
ref left,
|
||||
ref right,
|
||||
..
|
||||
}) => left.may_have_side_effects(ctx) || right.may_have_side_effects(ctx),
|
||||
Expr::Unary(UnaryExpr { arg, .. }) => arg.may_have_side_effects(ctx),
|
||||
Expr::Bin(BinExpr { left, right, .. }) => {
|
||||
left.may_have_side_effects(ctx) || right.may_have_side_effects(ctx)
|
||||
}
|
||||
|
||||
Expr::Member(MemberExpr { obj, prop, .. })
|
||||
if obj.is_object() || obj.is_fn_expr() || obj.is_arrow() || obj.is_class() =>
|
||||
@ -1444,7 +1442,7 @@ pub trait ExprExt {
|
||||
Expr::New(_) => true,
|
||||
|
||||
Expr::Call(CallExpr {
|
||||
callee: Callee::Expr(ref callee),
|
||||
callee: Callee::Expr(callee),
|
||||
ref args,
|
||||
..
|
||||
}) if callee.is_pure_callee(ctx) => {
|
||||
@ -1466,15 +1464,10 @@ pub trait ExprExt {
|
||||
|
||||
Expr::Call(_) | Expr::OptChain(..) => true,
|
||||
|
||||
Expr::Seq(SeqExpr { ref exprs, .. }) => {
|
||||
exprs.iter().any(|e| e.may_have_side_effects(ctx))
|
||||
}
|
||||
Expr::Seq(SeqExpr { exprs, .. }) => exprs.iter().any(|e| e.may_have_side_effects(ctx)),
|
||||
|
||||
Expr::Cond(CondExpr {
|
||||
ref test,
|
||||
ref cons,
|
||||
ref alt,
|
||||
..
|
||||
test, cons, alt, ..
|
||||
}) => {
|
||||
test.may_have_side_effects(ctx)
|
||||
|| cons.may_have_side_effects(ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user