Skip to content

Instantly share code, notes, and snippets.

@rexxars rexxars/input.js
Created Dec 1, 2017

Embed
What would you like to do?
Uglify JS bug
// Reduced/boiled down from a webpack bundle, obviously not the real thing
var zing = {};
(function foo(module, exports, __webpack_require__) {
"use strict";
exports.default = sortableContainer;
function sortableContainer(WrappedComponent) {
var _class,
_temp,
win = {};
return (
(_temp = _class = (function(_Component) {
function _createClass(unused, methods) {
var output = {};
methods.forEach(function(method) {
output[method.key] = method.value;
});
return output;
}
function _class(input) {
return input;
}
return _createClass(_class, [
{
key: "animateNodes",
value: function animateNodes() {
var _props3 = this.props,
nodes = [],
transitionDuration = _props3.transitionDuration,
hideSortableGhost = _props3.hideSortableGhost;
var deltaScroll = {
left: this.scrollContainer.scrollLeft - this.initialScroll.left,
top: this.scrollContainer.scrollTop - this.initialScroll.top
};
var sortingOffset = {
left:
this.offsetEdge.left + this.translate.x + deltaScroll.left,
top: this.offsetEdge.top + this.translate.y + deltaScroll.top
};
var scrollDifference = {
top: win.pageYOffset - this.initialWindowScroll.top,
left: win.pageXOffset - this.initialWindowScroll.left
};
for (var i = 0, len = nodes.length; i < len; i++) {
var node = nodes[i].node;
var index = node.sortableInfo.index;
var width = node.offsetWidth;
var height = node.offsetHeight;
var offset = {
width: this.width > width ? width / 2 : this.width / 2,
height: this.height > height ? height / 2 : this.height / 2
};
if (this.axis.y) {
if (
index < this.index &&
((sortingOffset.left +
scrollDifference.left -
offset.width <=
edgeOffset.left &&
sortingOffset.top + scrollDifference.top <=
edgeOffset.top + offset.height) ||
sortingOffset.top +
scrollDifference.top +
offset.height <=
edgeOffset.top)
) {
// Do something
}
}
}
return "it ran without issues";
}
}
]);
})()),
_temp
);
}
})({}, zing);
var f = zing.default();
console.log(
f.animateNodes.call({
axis: { y: 13 },
height: 300,
index: 2,
initialScroll: { left: 0, top: 0 },
initialWindowScroll: { left: 0, top: 0 },
offsetEdge: { left: 0, top: 0 },
props: { transitionDuration: 300, hideSortableGhost: false },
scrollContainer: { scrollLeft: 0, scrollTop: 0 },
translate: { x: 0, y: 0 },
width: 200
})
);
// Output: 'it ran without issues'
var zing={};!function(module,exports,__webpack_require__){"use strict";exports.default=function(WrappedComponent){var win={};return function(unused,methods){var output={};return[{key:"animateNodes",value:function(){for(var _props3=this.props,nodes=[],sortingOffset_left=(_props3.transitionDuration,_props3.hideSortableGhost,this.scrollContainer.scrollLeft,this.initialScroll.left,this.scrollContainer.scrollTop,this.initialScroll.top,this.offsetEdge.left+this.translate.x+deltaScroll.left),sortingOffset_top=this.offsetEdge.top+this.translate.y+deltaScroll.top,scrollDifference_top=win.pageYOffset-this.initialWindowScroll.top,scrollDifference_left=win.pageXOffset-this.initialWindowScroll.left,i=0,len=nodes.length;i<len;i++){var node=nodes[i].node,index=node.sortableInfo.index,width=node.offsetWidth,height=node.offsetHeight,offset_width=this.width>width?width/2:this.width/2,offset_height=this.height>height?height/2:this.height/2;this.axis.y&&index<this.index&&(sortingOffset_left+scrollDifference_left-offset_width<=edgeOffset.left&&sortingOffset_top+scrollDifference_top<=edgeOffset.top+offset_height||edgeOffset.top)}return"it ran without issues"}}].forEach(function(method){output[method.key]=method.value}),output}()}}(0,zing);var f=zing.default();console.log(f.animateNodes.call({axis:{y:13},height:300,index:2,initialScroll:{left:0,top:0},initialWindowScroll:{left:0,top:0},offsetEdge:{left:0,top:0},props:{transitionDuration:300,hideSortableGhost:!1},scrollContainer:{scrollLeft:0,scrollTop:0},translate:{x:0,y:0},width:200}));
// Output:
/*
ReferenceError: deltaScroll is not defined
at Object.value (/home/espenh/webdev/some-project/test.min.js:1:535)
at Object.<anonymous> (/home/espenh/webdev/some-project/test.min.js:1:1348)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)
at Function.Module.runMain (module.js:682:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:613:3
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.