Skip to content

Commit

Permalink
Handle ExportNamedDeclarations
Browse files Browse the repository at this point in the history
  • Loading branch information
Oskar Segersvärd committed Dec 15, 2015
1 parent 8a678fa commit 2a089f8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/instrumenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,8 @@
coverStatement: function (node, walker) {
var sName,
incrStatementCount,
parent,
insertionTarget,
grandParent;

this.maybeSkipNode(node, 'next');
Expand Down Expand Up @@ -817,7 +819,19 @@
)
)
);
this.splice(incrStatementCount, node, walker);

// The insertion target for `incrStatementCount` is usually the current node.
insertionTarget = node;

// However, to handle ExportNamedDeclarations, like `export var ...`
// We must insert the statement before our parent node,
// if it is such an export statement.
parent = walker.parent();
if (parent && parent.node.type === SYNTAX.ExportNamedDeclaration.name) {
insertionTarget = parent;
}

this.splice(incrStatementCount, insertionTarget, walker);
}
},

Expand Down Expand Up @@ -1048,4 +1062,3 @@
}

}(typeof module !== 'undefined' && typeof module.exports !== 'undefined' && typeof exports !== 'undefined'));

0 comments on commit 2a089f8

Please sign in to comment.