Skip to content

Commit

Permalink
Align with estree/estree#198
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Aug 11, 2019
1 parent 286c9af commit 8379ae3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
28 changes: 13 additions & 15 deletions lib/assets/JavaScript.js
Expand Up @@ -421,7 +421,19 @@ class JavaScript extends Text {
that.strict = true;
}

if (node.type === 'CallExpression') {
if (
node.type === 'ImportExpression' &&
node.source.type === 'Literal' &&
typeof node.source.value === 'string'
) {
if (isImportUrl(node.source.value)) {
outgoingRelations.push({
type: 'JavaScriptDynamicImport',
node,
href: node.source.value
});
}
} else if (node.type === 'CallExpression') {
const parentParentNode = stack[stack.length - 3];

if (
Expand Down Expand Up @@ -537,20 +549,6 @@ class JavaScript extends Text {
});
}
}
} else if (
node.type === 'CallExpression' &&
node.callee.type === 'Import' &&
node.arguments[0] &&
node.arguments[0].type === 'Literal' &&
typeof node.arguments[0].value === 'string'
) {
if (isImportUrl(node.arguments[0].value)) {
outgoingRelations.push({
type: 'JavaScriptDynamicImport',
node,
href: node.arguments[0].value
});
}
}
} else if (
node.type === 'NewExpression' &&
Expand Down
4 changes: 2 additions & 2 deletions lib/relations/JavaScriptDynamicImport.js
Expand Up @@ -2,11 +2,11 @@ const Relation = require('./Relation');

class JavaScriptDynamicImport extends Relation {
get href() {
return this.node.arguments[0].value;
return this.node.source.value;
}

set href(href) {
this.node.arguments[0].value = href;
this.node.source.value = href;
}

attach(position, adjacentRelation) {
Expand Down

0 comments on commit 8379ae3

Please sign in to comment.