[Pkg-javascript-commits] [node-lexical-scope] 17/83: right hand test passes with an extra check on the left-hand identifier parent type
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Dec 15 09:45:46 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-lexical-scope.
commit 26a748e5e161ac5f800231beae5a28e4a11c5d20
Author: James Halliday <mail at substack.net>
Date: Tue Feb 19 23:38:38 2013 -0800
right hand test passes with an extra check on the left-hand identifier parent type
---
index.js | 8 +++++++-
package.json | 2 +-
test/right_hand.js | 7 ++++---
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/index.js b/index.js
index dc0754b..1237ede 100644
--- a/index.js
+++ b/index.js
@@ -29,7 +29,13 @@ module.exports = function (src) {
if (isFunction(node.parent)) return;
if (node.parent.type === 'AssignmentExpression') {
- exported[node.name] = keyOf(node).length;
+ var isLeft0 = node.parent.left.type === 'MemberExpression'
+ && node.parent.left.object === node.name
+ ;
+ var isLeft1 = node.parent.left.type === 'Identifier';
+ if (isLeft0 || isLeft1) {
+ exported[node.name] = keyOf(node).length;
+ }
}
if (!exported[node.name]
|| exported[node.name] < keyOf(node).length) {
diff --git a/package.json b/package.json
index cfb4763..8966da4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "lexical-scope",
- "version": "0.0.2",
+ "version": "0.0.3",
"description": "detect global and local lexical identifiers from javascript source code",
"main": "index.js",
"dependencies": {
diff --git a/test/right_hand.js b/test/right_hand.js
index 2329773..3df78b9 100644
--- a/test/right_hand.js
+++ b/test/right_hand.js
@@ -6,9 +6,10 @@ test('globals on the right-hand of assignment', function (t) {
t.plan(3);
var scope = detect(src);
- t.same(scope.globals.implicit, [
- 'exports', '__dirname', '__filename'
- ]);
+ t.same(
+ scope.globals.implicit.sort(),
+ [ 'exports', '__dirname', '__filename' ].sort()
+ );
t.same(scope.globals.exported, []);
t.same(scope.locals, { '': [] });
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-lexical-scope.git
More information about the Pkg-javascript-commits
mailing list