check if node exists before inheriting comments to it

This commit is contained in:
Sebastian McKenzie
2014-12-29 01:37:12 +11:00
parent 213003a007
commit 03efd69998

View File

@@ -48,7 +48,7 @@ function traverse(parent, opts, scope) {
// inherit comments from original node to the first replacement node
var inheritTo = result;
if (isArray) inheritTo = result[0];
t.inheritsComments(inheritTo, node);
if (inheritTo) t.inheritsComments(inheritTo, node);
// replace the node
node = obj[key] = result;