Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround webkit parsing error #2056

Merged
merged 1 commit into from
Jun 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function OutputStream(options) {
semicolons : true,
shebang : true,
source_map : null,
webkit : false,
width : 80,
wrap_iife : false,
}, true);
Expand Down Expand Up @@ -597,6 +598,13 @@ function OutputStream(options) {
return true;
}

if (output.option('webkit')) {
var p = output.parent();
if (p instanceof AST_PropAccess && p.expression === this) {
return true;
}
}

if (output.option('wrap_iife')) {
var p = output.parent();
return p instanceof AST_Call && p.expression === this;
Expand Down
26 changes: 26 additions & 0 deletions test/compress/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,29 @@ issue_203: {
}
expect_stdout: "42"
}

no_webkit: {
beautify = {
webkit: false,
}
input: {
console.log(function() {
1 + 1;
}.a = 1);
}
expect_exact: "console.log(function(){1+1}.a=1);"
expect_stdout: "1"
}

webkit: {
beautify = {
webkit: true,
}
input: {
console.log(function() {
1 + 1;
}.a = 1);
}
expect_exact: "console.log((function(){1+1}).a=1);"
expect_stdout: "1"
}
4 changes: 2 additions & 2 deletions test/jetstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ if (typeof phantom == "undefined") {
});
var args = process.argv.slice(2);
if (!args.length) {
args.push("-mc");
args.push("-mcb", "beautify=false,webkit");
}
args.push("--timings");
var child_process = require("child_process");
try {
require("phantomjs-prebuilt");
} catch(e) {
child_process.execSync("npm install phantomjs-prebuilt@2.1.14");
child_process.execSync("npm install phantomjs-prebuilt@2.1.14 --no-save");
}
var http = require("http");
var server = http.createServer(function(request, response) {
Expand Down
1 change: 1 addition & 0 deletions test/mocha/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe("test/jetstream.js", function() {
it("Should pass with options " + options, function(done) {
var args = options.split(/ /);
args.unshift("test/jetstream.js");
args.push("-b", "beautify=false,webkit");
run(process.argv[0], args, done);
});
});
Expand Down