Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bind calls to ES5 constructors
  • Loading branch information
lukastaegert committed Nov 8, 2017
1 parent 2fb0c34 commit 503b8aa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ast/nodes/NewExpression.js
Expand Up @@ -2,6 +2,10 @@ import Node from '../Node.js';
import CallOptions from '../CallOptions';

export default class NewExpression extends Node {
bindNode () {
this.callee.bindCallAtPath( [], this._callOptions );
}

hasEffects ( options ) {
return this.arguments.some( child => child.hasEffects( options ) )
|| this.callee.hasEffectsWhenCalledAtPath( [], this._callOptions, options.getHasEffectsWhenCalledOptions() );
Expand All @@ -12,6 +16,6 @@ export default class NewExpression extends Node {
}

initialiseNode () {
this._callOptions = CallOptions.create( { withNew: true } );
this._callOptions = CallOptions.create( { withNew: true, args: this.arguments } );
}
}
@@ -0,0 +1,8 @@
var assert = require( 'assert' );

module.exports = {
description: 'Associates ES5 constructor parameters with their call arguments',
exports: function ( exports ) {
assert.equal( exports.bar, 'present' );
}
};
@@ -0,0 +1,11 @@
const foo = { mightBeExported: {} };
const exported = {};

function AssignExported ( obj ) {
obj.mightBeExported = exported;
}

const bar = new AssignExported( foo );
foo.mightBeExported.bar = 'present';

export default exported;

0 comments on commit 503b8aa

Please sign in to comment.