-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
We ran into an issue when compressing jQuery with the latest version (3.0.23). The README implies that the typeof should remain unchanged when unsafe is set to false. Nevertheless, only when setting ie8 to true did we get the expected output.
Sometimes, methods are invoked in IE9/IE10 when simply referencing them as properties. In this case, .getAttribute is called despite the lack of parens, throwing an error. Only when typeof remains untouched is the error avoided. Reduced example is below.
Bug report
ES5
Uglify version (uglifyjs -V)
uglify-js 3.0.23
JavaScript input
function attr (elem, name, value) {
// Fallback to prop when attributes are not supported
if (typeof elem.getAttribute === "undefined") {
return jQuery.prop(elem, name, value);
}
}The uglifyjs CLI command executed or minify() options used.
uglifyjs --compress -- test.jsor
uglifyjs --compress unsafe=false -- test.jsJavaScript output or error produced.
function attr(elem,name,value){if(void 0===elem.getAttribute)return jQuery.prop(elem,name,value)}Correct output is produced with
uglifyjs --ie8 --compress -- test.jsOutput being:
function attr(elem,name,value){if("undefined"==typeof elem.getAttribute)return jQuery.prop(elem,name,value)}Problem is, the output is unsafe for IE9/IE10 as well.