Skip to content

Commit 2f16e6c

Browse files
committed
exempt 3 call method chaining
fix #36.
1 parent b7a0a4d commit 2f16e6c

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

transforms/integration/__testfixtures__/set-value.input.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,13 @@ test('it renders', function(assert) {
1616
Ember.run(() => this.$('select').val('1').trigger('change'));
1717
Ember.run(() => this.$('#odd').val(10).trigger('input').trigger('blur'));
1818
this.$('#odd').val(10).trigger('input').trigger('blur');
19+
this.$('input:eq(0)')
20+
.val('foo')
21+
.trigger('keydown')
22+
.focusout();
23+
this.$('input:eq(0)')
24+
.val('foo')
25+
.trigger('keydown')
26+
.blur();
1927
assert.ok(true);
2028
});

transforms/integration/__testfixtures__/set-value.output.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,13 @@ test('it renders', async function(assert) {
1818
Ember.run(() => this.$('select').val('1').trigger('change'));
1919
Ember.run(() => this.$('#odd').val(10).trigger('input').trigger('blur'));
2020
this.$('#odd').val(10).trigger('input').trigger('blur');
21+
this.$('input:eq(0)')
22+
.val('foo')
23+
.trigger('keydown')
24+
.focusout();
25+
this.$('input:eq(0)')
26+
.val('foo')
27+
.trigger('keydown')
28+
.blur();
2129
assert.ok(true);
2230
});

transforms/integration/transforms/set-value.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ function isJQueryExpression(j, path) {
5353
&& !hasFluentTriggerCall(j, path.parent.parent)
5454
)
5555
)
56+
&& !hasFluentTriggerAndMoreCall(j, path);
5657
}
5758

5859
function hasFluentTriggerCall(j, path) {
@@ -67,6 +68,13 @@ function hasFluentTriggerCall(j, path) {
6768
;
6869
}
6970

71+
function hasFluentTriggerAndMoreCall(j, path) {
72+
const greatGrandParent = path.parentPath.parentPath.parentPath.node;
73+
return greatGrandParent
74+
&& j.MemberExpression.check(greatGrandParent)
75+
;
76+
}
77+
7078
function hasFluentChangeCall(j, path) {
7179
let parent = path.parent && path.parent.node;
7280
let grandParent = parent && path.parent.parent.node;
@@ -103,7 +111,6 @@ function transform(file, api) {
103111
let triggerReplacements = replacements
104112
.filter((path) => hasFluentTriggerCall(j, path))
105113
.map((path) => path.parent.parent.parent)
106-
// .insertAfter((path) => j.expressionStatement(createTriggerExpression(j, path.node.expression.callee.object.argument.arguments[0], path.node.expression.arguments[0])))
107114
.replaceWith((path) => j.expressionStatement(path.node.expression.callee.object))
108115
.forEach((path) => makeParentFunctionAsync(j, path));
109116

0 commit comments

Comments
 (0)