[Pkg-javascript-commits] [uglifyjs] 26/50: fix parsing of property access after new line (#1944)
Jonas Smedegaard
dr at jones.dk
Thu Aug 17 23:06:45 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository uglifyjs.
commit 6cd580dc23c25fd90b4284fd3bac5b4c3c8c1a10
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Tue May 16 05:40:49 2017 +0800
fix parsing of property access after new line (#1944)
Account for comments when detecting property access in `tokenizer`.
fixes #1943
---
lib/parse.js | 6 +++++-
test/compress/issue-1943.js | 31 +++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/lib/parse.js b/lib/parse.js
index b9911fa..014822a 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -285,7 +285,11 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX(value)) ||
(type == "keyword" && KEYWORDS_BEFORE_EXPRESSION(value)) ||
(type == "punc" && PUNC_BEFORE_EXPRESSION(value)));
- prev_was_dot = (type == "punc" && value == ".");
+ if (type == "punc" && value == ".") {
+ prev_was_dot = true;
+ } else if (!is_comment) {
+ prev_was_dot = false;
+ }
var ret = {
type : type,
value : value,
diff --git a/test/compress/issue-1943.js b/test/compress/issue-1943.js
new file mode 100644
index 0000000..69bb9e6
--- /dev/null
+++ b/test/compress/issue-1943.js
@@ -0,0 +1,31 @@
+operator: {
+ input: {
+ a. //comment
+ typeof
+ }
+ expect_exact: "a.typeof;"
+}
+
+name: {
+ input: {
+ a. //comment
+ b
+ }
+ expect_exact: "a.b;"
+}
+
+keyword: {
+ input: {
+ a. //comment
+ default
+ }
+ expect_exact: "a.default;"
+}
+
+atom: {
+ input: {
+ a. //comment
+ true
+ }
+ expect_exact: "a.true;"
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list